-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-120029: make symtable.Symbol.__repr__
correctly reflect the compiler's flags
#120099
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
- restore 'symtable.SCOPE_OFF' for compatibility purposes - fix `Symbol.is_comp_cell()`
Thank you for the review Serhiy. By the way, is it fine for me to re-request a review after addressing what you've reviewed or do you prefer not to have notifications' noise (same question for Jelle)? |
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.
LGTM.
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.
DEF_FREE_CLASS
is used in a case like this:
def f():
x = 1
class C:
x = 2
def method(self):
return x
The method()
method should return 1
-- it doesn't see the class-scoped x
, but it does see the function-scoped x
outside the class. The class-scoped x
is marked DEF_FREE_CLASS
in this case, to make that work.
It's such a niche use that I don't think we are going to find a method name here that nicely represents it in an intuitive way. Best option is probably just is_free_class
to match the flag name.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Ah, I should have said "I have made the requested changes; please review again". |
Thanks for making the requested changes! @carljm, @serhiy-storchaka: please review the changes made to this pull request. |
Misc/NEWS.d/next/Library/2024-06-05-11-03-10.gh-issue-120029.QBsw47.rst
Outdated
Show resolved
Hide resolved
I think this now needs to be updated for compatibility with the merge of the PEP 649 compiler implementation. |
…e compiler's flags, add methods (python#120099) Expose :class:`symtable.Symbol` methods :meth:`~symtable.Symbol.is_free_class`, :meth:`~symtable.Symbol.is_comp_iter` and :meth:`~symtable.Symbol.is_comp_cell`. --------- Co-authored-by: Carl Meyer <[email protected]>
…e compiler's flags, add methods (python#120099) Expose :class:`symtable.Symbol` methods :meth:`~symtable.Symbol.is_free_class`, :meth:`~symtable.Symbol.is_comp_iter` and :meth:`~symtable.Symbol.is_comp_cell`. --------- Co-authored-by: Carl Meyer <[email protected]>
…e compiler's flags, add methods (python#120099) Expose :class:`symtable.Symbol` methods :meth:`~symtable.Symbol.is_free_class`, :meth:`~symtable.Symbol.is_comp_iter` and :meth:`~symtable.Symbol.is_comp_cell`. --------- Co-authored-by: Carl Meyer <[email protected]>
I did not expose
is_free_class
yet because I don't really know whether it's the best name or not, nor did I handle theDEF_FREE
flag because I don't know its difference with theFREE
scope itself (see #120029 (comment)).I've nonethless cleaned up the lambda functions used to getting the scope
and also exportedSCOPE_OFFSET
instead ofSCOPE_OFF
(those constants are actually private since they are not documented so it should not affect public API). I can revert those changes easily though if you want me to make them in another PR.cc @JelleZijlstra @carljm
symtablemodule.c
#120029📚 Documentation preview 📚: https://cpython-previews--120099.org.readthedocs.build/