bpo-1875, bpo-32477: Raise SyntaxError in invalid blocks that will be optimized away. by serhiy-storchaka · Pull Request #14116 · python/cpython
… 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.
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 | |||
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'
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: I have made the requested changes; please review again.
| } | ||
| default: | ||
| default: { | ||
| if (e->kind == Constant_kind) { |
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: )
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
| * constant = 1: "if 1", "if 2", ... | ||
| * constant = -1: rest */ | ||
| if (constant == 0) { | ||
| BEGIN_DO_NOT_EMIT_BYTECODE |
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters