ironm73 / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

raise the Python exception instead of JSError #63

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
import PyV8

class TestException(Exception):
    def __init__(self):
        pass

    def __str__(self):
        return "test exception"

class Global(PyV8.JSClass):

    def __init__(self):

        pass

    def testExceptions(self):
        raise TestException()

ctx = PyV8.JSContext(Global())
ctx.enter()
ctx.eval("""testExceptions()""") 

What is the expected output? What do you see instead?

pyv8 should raise the Python exception instead of JSError

Traceback (most recent call last):
    ctx.eval("""testExceptions()""")
PyV8.JSError: JSError: Error (  @ 1 : 0 )  -> testExceptions() 

What version of the product are you using? On what operating system?

Latest SVN trunk

Please provide any additional information below.

Original issue reported on code.google.com by flier...@gmail.com on 14 Dec 2010 at 2:20

GoogleCodeExporter commented 8 years ago
Please verify the issue with SVN trunk after r310

    def testExceptionMapping(self):
        class TestException(Exception):
            pass

        class Global(JSClass):  
            def raiseExceptions(self):
                raise TestException()
        with JSContext(Global()) as ctxt:
            self.assertRaises(TestException, ctxt.eval, "this.raiseExceptions();")

Original comment by flier...@gmail.com on 15 Dec 2010 at 5:14

GoogleCodeExporter commented 8 years ago
The current implementation may introduce a slight memory leak, because pyv8 
must trace the Python exception in the Javascript exception, if the JS 
exception was eaten by JS code, those Python exception may not be collected. 
Because I can't find any way to trace the lifecycle of Javascript object.

Original comment by flier...@gmail.com on 15 Dec 2010 at 5:17