bpo-1875, bpo-32477: Raise SyntaxError in invalid blocks that will be optimized away.#14116
bpo-1875, bpo-32477: Raise SyntaxError in invalid blocks that will be optimized away.#14116serhiy-storchaka wants to merge 3 commits intopython:masterfrom
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.
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.
'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.
You need to update this test:
https://github.com/python/cpython/blob/master/Lib/test/test_sys_settrace.py#L62
|
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.
Shouldn't this be it's on case in the previous switch?
(case Constant_kind: )
|
@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.
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