-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Implement PEP 626 -- Precise line numbers for debugging #86412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Implementation of PEP-626 requires:
Guaranteeing that f_lineno is correct without hurting performance PEP-626 mandates that the f_lineno attribute of a frame is always correct, even after a return or raise, but we don't want to hurt performance. The front-end generates artificial RERAISEs and RETURN_VALUE that have no line number. To give these instructions a valid line number we can take advantage of the fact that such terminator blocks (blocks with no successors) can be freely duplicated. Once duplicated, each terminator block will have only one predecessor and can acquire the line number of the preceding block, without causing false line events. |
I'm happy that we are removing BEGIN_DO_NOT_EMIT_BYTECODE and END_DO_NOT_EMIT_BYTECODE but could you elaborate how this is related? These macros protect the compiler from emitting bytecode that corresponds to deaf code and by definition, unreachable. Could you give an example of a situation in which they create something that messes up the line numbers? Is this something to be with cleanup blocks in dead code or something similar? |
The following code is completely eliminated by the macros.
PEP-626 says that all executed lines of code must generate trace events, Dead code elimination will remove the |
Gotcha. I am pretty sure that this will have a similar problem as the coverage people were claiming when we were not properly removing all dead code (slightly less coverage percentage). This is not a problem of course, but we should ping the coverage folks so they are aware of this. |
This change introduced reference leaks: 5 tests failed: For example: $ ./python -m test test_syntax -R 3:3 -m test.test_syntax.SyntaxTestCase.test_no_indent
0:00:00 load avg: 1.59 Run tests sequentially
0:00:00 load avg: 1.59 [1/1] test_syntax
beginning 6 repetitions
123456
......
test_syntax leaked [27, 27, 27] references, sum=81
test_syntax leaked [20, 20, 20] memory blocks, sum=60
test_syntax failed == Tests result: FAILURE == 1 test failed: Total duration: 955 ms |
Mark, BTW: I have run the coverage.py test suite on 3.10.0a3, and as expected there are failures. I haven't dug into it yet to see what looks expected and what does not. I also see there are still changes happening on master, so I'm not sure when to commit the time. |
Ned, I'd like to take a look, to see if things are as expected, and if there are any tests we can add to CPython. |
幹你娘 |
全家死光 |
幹你娘 |
你全家死光 |
幹你娘 |
Mark, I'm categorizing and characterizing the test failures. Here's the start of it: https://gist.github.com/nedbat/6c5dedde9df8d2de13de8a6a39a5f112 Let me know what other information would be useful. |
Thanks Ned, that's really helpful. I'll go through those points: Code after break/continue is no longer compiled. First line number of modules Except clause when no exception Double loops (this also covers End-of-loop jumps, I think) I want to merge #23743 before I fix any of the others, but here is a summary of what I think are the root causes. if-break Finally handling |
#23780 fixes the finally handling. |
All done :) |
Is there a reason PEP-626 isn't yet mentioned in https://docs.python.org/3.10/whatsnew/3.10.html ? |
No. We should add it. |
PEP-626 deprecates co_lnotab, co_lnotab: https://www.python.org/dev/peps/pep-0626/#id15 This doesn't seem to be mentioned in the What's new document and is quite important. Mark, do you mind creating a PR for this? I could do it and add you as a reviewer if you wish |
f_lasti
, and thusf_lineno
, is set correctly after raising or reraising an exception #23803Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: