-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
bpo-1875, bpo-32477: Raise SyntaxError in invalid blocks that will be optimized away. #14116
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
Conversation
… optimized away. Also simplify the code generator and peepholer for "if" and "while" with constant condition. Also optimize more cases of conditional jumps with constant condition.
009e558 to
775fda6
Compare
pablogsal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Serhiy!
I left some minor comments
| @@ -0,0 +1,3 @@ | |||
| A :exc:`SyntaxError` is now always raised if a code blocks that will be | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'if code blocks' or 'if a code block'
|
It seems that this is causing some errors with trace functions |
pablogsal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
When you're done making the requested changes, leave the comment: |
| } | ||
| default: | ||
| default: { | ||
| if (e->kind == Constant_kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be it's on case in the previous switch?
(case Constant_kind: )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
|
@serhiy-storchaka I think we should merge this sooner than later so it can be in the next 3.8 beta release and people can interact with it more. If you don't have time I can push to the PR to fix the failing test (https://github.com/python/cpython/blob/master/Lib/test/test_sys_settrace.py#L62) if you prefer :) |
|
No, this PR is not ready yet. |
| * constant = 1: "if 1", "if 2", ... | ||
| * constant = -1: rest */ | ||
| if (constant == 0) { | ||
| BEGIN_DO_NOT_EMIT_BYTECODE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this macro and the attribute in the compiler struct if is not used anymore
|
This change was implemented as part of PEP 626, so this PR is now obsolete. |
Also simplify the code generator and peepholer for "if" and "while" with
constant condition.
Also optimize more cases of conditional jumps with constant condition.
https://bugs.python.org/issue1875
https://bugs.python.org/issue32477