Skip to content

Commit

Permalink
Add unit test for python exceptions in async environments.
Browse files Browse the repository at this point in the history
  • Loading branch information
qwenger committed Oct 30, 2021
1 parent 25979f8 commit c603994
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test_quickjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ def test_list():
# instead of a JS exception.
self.context.eval("test_list()")

def test_python_exception_with_object_return_does_not_raise_system_error(self):
# https://github.com/PetterS/quickjs/issues/66

def python_raise():
raise Exception

self.context.add_callable("python_raise", python_raise)
# When called, `a` should return an object (a promise),
# even though a Python error is generated in the background.
self.context.eval("async function a() {await python_raise();}")
# With incorrect error handling, this raised a SystemError in dev builds,
# and segfaulted in prod builds.
self.assertEqual(self.context.eval("typeof a();"), "object")


class Object(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit c603994

Please sign in to comment.