diff options
| author | shadchin <[email protected]> | 2024-08-17 21:51:59 +0300 |
|---|---|---|
| committer | shadchin <[email protected]> | 2024-08-17 22:04:51 +0300 |
| commit | ee9edbd8878888bafcd0eeb3b528f3ec4311560b (patch) | |
| tree | d54d8138e50a446904f10a2092719be86af011b7 /contrib/tools/python3/Python/symtable.c | |
| parent | 72cbe4bad58add0912623ba51351ff1db8587249 (diff) | |
Update Python 3 to 3.12.5
https://docs.python.org/release/3.12.5/whatsnew/changelog.html#python-3-12-5-final
de86cdeacd3a8653b9ec36e87975886fafcf6dc2
Diffstat (limited to 'contrib/tools/python3/Python/symtable.c')
| -rw-r--r-- | contrib/tools/python3/Python/symtable.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/contrib/tools/python3/Python/symtable.c b/contrib/tools/python3/Python/symtable.c index ba4284210bb..f99ca4fdd06 100644 --- a/contrib/tools/python3/Python/symtable.c +++ b/contrib/tools/python3/Python/symtable.c @@ -675,22 +675,19 @@ inline_comprehension(PySTEntryObject *ste, PySTEntryObject *comp, if (existing == NULL && PyErr_Occurred()) { return 0; } + // __class__ is never allowed to be free through a class scope (see + // drop_class_free) + if (scope == FREE && ste->ste_type == ClassBlock && + _PyUnicode_EqualToASCIIString(k, "__class__")) { + scope = GLOBAL_IMPLICIT; + if (PySet_Discard(comp_free, k) < 0) { + return 0; + } + remove_dunder_class = 1; + } if (!existing) { // name does not exist in scope, copy from comprehension assert(scope != FREE || PySet_Contains(comp_free, k) == 1); - if (scope == FREE && ste->ste_type == ClassBlock && - _PyUnicode_EqualToASCIIString(k, "__class__")) { - // if __class__ is unbound in the enclosing class scope and free - // in the comprehension scope, it needs special handling; just - // letting it be marked as free in class scope will break due to - // drop_class_free - scope = GLOBAL_IMPLICIT; - only_flags &= ~DEF_FREE; - if (PySet_Discard(comp_free, k) < 0) { - return 0; - } - remove_dunder_class = 1; - } PyObject *v_flags = PyLong_FromLong(only_flags); if (v_flags == NULL) { return 0; |
