Skip to content

Give class-closure cells private names so they don't collide with freevars - #159131

Draft
iritkatriel wants to merge 1 commit into
python:mainfrom
iritkatriel:private-class-closure-cells
Draft

iritkatriel wants to merge 1 commit into
python:mainfrom
iritkatriel:private-class-closure-cells

Conversation

@iritkatriel

Copy link
Copy Markdown
Member

Summary

  • Store the class unit's synthetic cells as __classcell__ / __classdictcell__ instead of __class__ / __classdict__.
  • Map method freevars of the public names to those private cells in _PyCompile_LookupArg.
  • This keeps an enclosing free named __class__ distinct from the class cell in localsplus, removing the need to special-case those names as if they were ordinary freevars that share a spelling with the class cell.

Test plan

  • ./python.exe -m test test_super test_listcomps test_symtable
  • CI

Made with Cursor

…evars

Store the class unit's synthetic cells as __classcell__/__classdictcell__
instead of __class__/__classdict__, and map method freevars of the public
names to those private cells in LookupArg. This keeps an enclosing free
named __class__ distinct from the class cell in localsplus.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant