You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add file and line numbers to exception traceback (#28)
- CPython does not expose any sane way to set the traceback
of an exception that does not orginate from a CPython
exception. In particular, __traceback__ must be an
internal Traceback type, and that Traceback type
cannot be constructed without using internal frame
and code types, which also cannot be constructed.
- To get around this, we exploit the traceback module,
which does not care about types and only care about
interfaces. This allow us to use our own fake frame
and code classes that match their interface.
- We exploit object.__new__ to create an instance of
TracebackException without calling its constructor,
and set all its fields manually
- To set the stack field, we use StackSummary.from_list.
with the Java traceback.
- Python 3.10 has a quirk: it calls RERAISE in
the finally block corresponding to an except
block. That finally immediately calls RERAISE,
but TOS is a type, so that exception loses both
it cause and message. So work around this,
we deviate a bit from how the code apparently
works
- After finally branch is taken, stack is
<old stack> <block (3 items)> traceback, exeception, exception
instead of
<old stack> <block (3 items)> traceback, exeception, type
- JUMP_IF_NOT_EXEC_MATCH is now an instanceof
instead of issubclass
This works since Python pops off all these values when
actually entering the code for an except block, and
JUMP_IF_NOT_EXEC_MATCH is the only opcode that can
be encountered.
- Python 3.10 has a quirk: it calls RERAISE in
the finally block corresponding to an except
block. That finally immediately calls RERAISE,
but TOS is a type, so that exception loses both
it cause and message. So work around this,
we deviate a bit from how the code apparenty
works
- After finally branch is taken, stack is
<old stack> <block (3 items)> traceback, exeception, exception
instead of
<old stack> <block (3 items)> traceback, exeception, type
- JUMP_IF_NOT_EXEC_MATCH is now an instanceof
instead of issubclass
This works since Python pops off all these values when
actually entering the code for an except block, and
JUMP_IF_NOT_EXEC_MATCH is the only opcode that can
be encountered.
- Fix a bug in generating traceback
- Make it more clear that locals refer to the built-in function
- Update CI after CI changes in Timefold Solver
0 commit comments