Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-1875, bpo-32477: Raise SyntaxError in invalid blocks that will be optimized away.#14116

Closed
serhiy-storchaka wants to merge 3 commits into
python:masterpython/cpython:masterfrom
serhiy-storchaka:optimize-jumps2serhiy-storchaka/cpython:optimize-jumps2Copy head branch name to clipboard
Closed

bpo-1875, bpo-32477: Raise SyntaxError in invalid blocks that will be optimized away.#14116
serhiy-storchaka wants to merge 3 commits into
python:masterpython/cpython:masterfrom
serhiy-storchaka:optimize-jumps2serhiy-storchaka/cpython:optimize-jumps2Copy head branch name to clipboard

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 15, 2019

Copy link
Copy Markdown
Member

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

… 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.

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

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

Comment thread Python/compile.c Outdated
Comment thread Lib/test/test_syntax.py Outdated
Comment thread Python/compile.c
Comment thread Python/compile.c
Comment thread Python/compile.c
@@ -0,0 +1,3 @@
A :exc:`SyntaxError` is now always raised if a code blocks that will be

Copy link
Copy Markdown
Member

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'

@pablogsal

Copy link
Copy Markdown
Member

It seems that this is causing some errors with trace functions

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bedevere-bot

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Comment thread Python/compile.c
}
default:
default: {
if (e->kind == Constant_kind) {

Copy link
Copy Markdown
Member

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: )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

@pablogsal

Copy link
Copy Markdown
Member

@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 :)

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

No, this PR is not ready yet.

Comment thread Python/compile.c
* constant = 1: "if 1", "if 2", ...
* constant = -1: rest */
if (constant == 0) {
BEGIN_DO_NOT_EMIT_BYTECODE

Copy link
Copy Markdown
Member

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

@markshannon

Copy link
Copy Markdown
Member

This change was implemented as part of PEP 626, so this PR is now obsolete.

@markshannon markshannon closed this Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.