bpo-44446: set lineno in generator instructions #26782
Conversation
d078463
to
640f0a0
When generator instructions were added to bytecode, lineno was always set to -1, instead of the line number. This patch sets the lineno, if there is one. Signed-off-by: Filipe Laíns <lains@riseup.net>
|
@markshannon I do not understand why this patch is causing the behavior that it is, I would have guessed that this is a fairly innocuous change, do you have any idea of what is happening? |
|
See #26781 (comment) |
Indeed, I am right, this is an ownership issue with the locals dictionary: @markshannon, please take a look at this seems to be a regression either of PEP 626 or the latest changes in the frames/code object. I am not fully sure if you are accounting on this but I honestly don't see how we could have dropped the ownership of the locals dict when |
|
I think the issue might be in the new 3.11 bytecode. Before falling out to Lines 2473 to 2476 in a317778 After some digging, it seems like we are poping from an empty stack. What we end up popping in the test that triggers the assert happens to be the locals dict, which then gets decref'ed, and blows up afterwards. --- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2457,6 +2457,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
}
case TARGET(GEN_START): {
+ assert(!EMPTY());
PyObject *none = POP();
Py_DECREF(none);
if (!Py_IsNone(none)) {I have also managed to trigger another issue. --- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -1447,6 +1447,7 @@ def test_jump_backwards_out_of_with_block(output):
async def test_jump_backwards_out_of_async_with_block(output):
output.append(1)
async with asynctracecontext(output, 2):
+ global test
output.append(3)
@jump_test(2, 5, [5])Line 2248 in a317778 |
|
If you have any tips on how to use lltrace, that'd be very helpful, I haven't managed to figure that out |
Yeah, wait for #26822 to land and then just set |
When generator instructions were added to bytecode, lineno was always set to -1,
instead of the line number. This patch sets the lineno, if there is one.
Signed-off-by: Filipe Laíns lains@riseup.net
https://bugs.python.org/issue44446