I'm using PyV8 and I'd like to disallow assigning javascript objects to my python objects because of a current memory leak bug with PyV8. I came upwith this code:
def __setattr__(self, name, val):
if isinstance(val, (PyV8.JSFunction, PyV8.JSObject)):
raise ValueError("Can't put js objects on py values")
object.__setattr__(self, name, val)
However, the traceback I get when I do this is not very helpful:
Traceback (most recent call last):
File "pyv8-bug-186.py", line 142, in <module>
""")
File "pyv8-bug-186.py", line 75, in run_case
obj = ctxt.eval(js)
ValueError: Can't put js objects on py values
Particularly, it gives no information at all about which javascript file was running or what the line number was, etc. I see two potential solutions:
How would I go about doing either?
Not sure if this is by design, but for now, raise TypeError()
from within Python causes a javascript exception to be raised and displayed (along with line and column numbers). Great success!