aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/symtable.c
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2024-08-19 16:16:30 +0200
committerGitHub <noreply@github.com>2024-08-19 17:16:30 +0300
commit9b567afd3339f4525feab53873592cb025b14251 (patch)
tree5c8489f98dc5a9a10f66065055e5a401bbd14767 /contrib/tools/python3/Python/symtable.c
parent47bd121575c210d4bbb2dddcc2131759a694df05 (diff)
downloadydb-9b567afd3339f4525feab53873592cb025b14251.tar.gz
Library import 240819-0942 (#7994)
Co-authored-by: robot-piglet <robot-piglet@yandex-team.com> Co-authored-by: hiddenpath <hiddenpath@yandex-team.com> Co-authored-by: bulatman <bulatman@yandex-team.com> Co-authored-by: robot-contrib <robot-contrib@yandex-team.com> Co-authored-by: osidorkin <osidorkin@yandex-team.com> Co-authored-by: akhropov <akhropov@yandex-team.com> Co-authored-by: akozhikhov <akozhikhov@yandex-team.com> Co-authored-by: orlovorlov <orlovorlov@yandex-team.com> Co-authored-by: babenko <babenko@yandex-team.com> Co-authored-by: shadchin <shadchin@yandex-team.com> Co-authored-by: dmasloff <dmasloff@yandex-team.com> Co-authored-by: aleksei-le <aleksei-le@yandex-team.com> Co-authored-by: coteeq <coteeq@yandex-team.com> Co-authored-by: dimdim11 <dimdim11@yandex-team.com> Co-authored-by: robot-ya-builder <robot-ya-builder@yandex-team.com> Co-authored-by: iaz1607 <iaz1607@yandex-team.com>
Diffstat (limited to 'contrib/tools/python3/Python/symtable.c')
-rw-r--r--contrib/tools/python3/Python/symtable.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/contrib/tools/python3/Python/symtable.c b/contrib/tools/python3/Python/symtable.c
index ba4284210b..f99ca4fdd0 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;