Skip to content

Commit c603994

Browse files
committed
Add unit test for python exceptions in async environments.
1 parent 25979f8 commit c603994

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test_quickjs.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,20 @@ def test_list():
243243
# instead of a JS exception.
244244
self.context.eval("test_list()")
245245

246+
def test_python_exception_with_object_return_does_not_raise_system_error(self):
247+
# https://github.com/PetterS/quickjs/issues/66
248+
249+
def python_raise():
250+
raise Exception
251+
252+
self.context.add_callable("python_raise", python_raise)
253+
# When called, `a` should return an object (a promise),
254+
# even though a Python error is generated in the background.
255+
self.context.eval("async function a() {await python_raise();}")
256+
# With incorrect error handling, this raised a SystemError in dev builds,
257+
# and segfaulted in prod builds.
258+
self.assertEqual(self.context.eval("typeof a();"), "object")
259+
246260

247261
class Object(unittest.TestCase):
248262
def setUp(self):

0 commit comments

Comments
 (0)