PetterS / quickjs

Thin Python wrapper of https://bellard.org/quickjs/
https://github.com/bellard/QuickJS
MIT License
177 stars 19 forks source link

Fix #63: display traceback for exceptions in callables #64

Closed qwenger closed 2 years ago

qwenger commented 2 years ago

Simple attempt for #63 . PyErr_WriteUnraisable seems to fit the bill quite well with minimal work.

Test:

>>> import quickjs
>>> def test():
...     1/0
... 
>>> ctx = quickjs.Context()
>>> ctx.add_callable("test", test)
>>> ctx.eval("test()")
Exception ignored in: <function test at 0x7efe29521940>
Traceback (most recent call last):
  File "<stdin>", line 2, in test
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
_quickjs.JSException: InternalError: Python call failed.
    at test (native)
    at <eval> (<input>)
qwenger commented 2 years ago

Closing in favor of #67.