gh-153849: Expose scope attributes on symtable entries#153850
gh-153849: Expose scope attributes on symtable entries#153850serhiy-storchaka wants to merge 2 commits into
Conversation
The symbol table analysis computes a number of per-scope attributes that the compiler relies on, but did not expose them. Add read-only attributes to the symbol table entries: is_generator, is_coroutine, has_annotations, has_conditional_annotations, needs_class_closure, needs_classdict, can_see_class_scope and annotation_block. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts: # Lib/test/test_symtable.py
JelleZijlstra
left a comment
There was a problem hiding this comment.
This is exposing private implementation details of the compiler that we might want to change later. What would the backward compatibility implications be if we want to (for example) get rid of can_see_class_scope in a later version?
|
First of all, this attributes are added to a class in private module Currently I am playing with Python implementation of the compiler. None of these attributes are essential, they can be derived from the AST, and the first version of the compiler did it. But they are not trivially derivable. Exposing them in |
JelleZijlstra
left a comment
There was a problem hiding this comment.
OK, if this stays limited to a private module I have no concerns.
The symbol table analysis computes a number of per-scope attributes that the compiler relies on, but did not expose them. Add read-only attributes to the low-level symbol table entries:
is_generator,is_coroutine,has_annotations,has_conditional_annotations,needs_class_closure,needs_classdict,can_see_class_scopeandannotation_block.Attributes that are trivially derivable from the AST (such as whether a function has a
*argsparameter) are deliberately not included; they can be added later.🤖 Generated with Claude Code