Skip to content

gh-122245: move checks for writes and shadowing of __debug__ to symtable #122246

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

Merged
merged 8 commits into from
Jul 26, 2024

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Jul 24, 2024

@iritkatriel iritkatriel requested a review from jeremyhylton July 24, 2024 21:59
Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

Looks good.

@iritkatriel iritkatriel merged commit bc94cf7 into python:main Jul 26, 2024
37 checks passed
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

I started a review but never submitted it, sorry. None of these suggested changes seem crucial, but consider adding them if you like.

Comment on lines +2264 to +2267
>>> type __debug__ = int
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>>> type __debug__ = int
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__
>>> type __debug__ = int
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__
>>> class A[__debug__]: pass
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

In a similar vein

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, should have waited a bit longer. I'll add this.

@@ -0,0 +1,4 @@
Detection of writes to ``__debug__`` is moved from the compiler's codegen
stage to the symtable. This means that these errors now detected even in
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
stage to the symtable. This means that these errors now detected even in
stage to the symtable. This means that these errors are now detected even in

Detection of writes to ``__debug__`` is moved from the compiler's codegen
stage to the symtable. This means that these errors now detected even in
code that is optimized away before codegen (such as assertions with the
:option:`-O` command line option.)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
:option:`-O` command line option.)
:option:`-O` command line option).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move detection of writes and shadowing of __debug__ from compiler to symtable.
3 participants