8000 gh-120029: make `symtable.Symbol.__repr__` correctly reflect the compiler's flags by picnixz · Pull Request #120099 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 26 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert to using SCOPE_OFF
  • Loading branch information
picnixz committed Jun 6, 2024
commit 388e40e22114942c11d67e677a24889bb0dbbbb0
6 changes: 2 additions & 4 deletions Lib/symtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
DEF_FREE, DEF_FREE_CLASS,
DEF_IMPORT, DEF_BOUND, DEF_ANNOT,
DEF_COMP_ITER, DEF_COMP_CELL,
SCOPE_OFFSET, SCOPE_MASK,
SCOPE_OFF, SCOPE_MASK,
FREE, LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL
)

import weakref

__all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"]

SCOPE_OFF = SCOPE_OFFSET # kept for backward compatibility


def symtable(code, filename, compile_type):
""" Return the toplevel *SymbolTable* for the source code.
Expand Down Expand Up @@ -165,7 +163,7 @@ def get_children(self):


def _get_scope(flags): # like _PyST_GetScope()
return (flags >> SCOPE_OFFSET) & SCOPE_MASK
return (flags >> SCOPE_OFF) & SCOPE_MASK


class Function(SymbolTable):
Expand Down
2 changes: 1 addition & 1 deletion Modules/symtablemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ symtable_init_constants(PyObject *m)
if (PyModule_AddIntMacro(m, FREE) < 0) return -1;
if (PyModule_AddIntMacro(m, CELL) < 0) return -1;

if (PyModule_AddIntMacro(m, SCOPE_OFFSET) < 0) return -1;
if (PyModule_AddIntConstant(m, "SCOPE_OFF", SCOPE_OFFSET) < 0) return -1;
if (PyModule_AddIntMacro(m, SCOPE_MASK) < 0) return -1;

return 0;
Expand Down
0