summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/symtable.c
diff options
context:
space:
mode:
authorshadchin <[email protected]>2026-05-07 07:27:37 +0300
committershadchin <[email protected]>2026-05-07 07:57:26 +0300
commitcdd663c58847eced4c810b05edda251c70a10438 (patch)
tree268b4bf9860a9c77564d93a803d7ecfedd3586cd /contrib/tools/python3/Python/symtable.c
parentb6f47db70a8a8e904e3f38bed557097ff00f0b3b (diff)
Update Python 3 to 3.13.13
commit_hash:526db1f6570443324e2690db042314848cd47d2e
Diffstat (limited to 'contrib/tools/python3/Python/symtable.c')
-rw-r--r--contrib/tools/python3/Python/symtable.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/contrib/tools/python3/Python/symtable.c b/contrib/tools/python3/Python/symtable.c
index 5322c5e9597..f60af2b6955 100644
--- a/contrib/tools/python3/Python/symtable.c
+++ b/contrib/tools/python3/Python/symtable.c
@@ -763,6 +763,8 @@ inline_comprehension(PySTEntryObject *ste, PySTEntryObject *comp,
PyObject *k, *v;
Py_ssize_t pos = 0;
int remove_dunder_class = 0;
+ int remove_dunder_classdict = 0;
+ int remove_dunder_cond_annotations = 0;
while (PyDict_Next(comp->ste_symbols, &pos, &k, &v)) {
// skip comprehension parameter
@@ -782,15 +784,27 @@ 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
+ // __class__, __classdict__ and __conditional_annotations__ are
+ // never allowed to be free through a class scope (see
// drop_class_free)
if (scope == FREE && ste->ste_type == ClassBlock &&
- _PyUnicode_EqualToASCIIString(k, "__class__")) {
+ (_PyUnicode_EqualToASCIIString(k, "__class__") ||
+ _PyUnicode_EqualToASCIIString(k, "__classdict__") ||
+ _PyUnicode_EqualToASCIIString(k, "__conditional_annotations__"))) {
scope = GLOBAL_IMPLICIT;
if (PySet_Discard(comp_free, k) < 0) {
return 0;
}
- remove_dunder_class = 1;
+
+ if (_PyUnicode_EqualToASCIIString(k, "__class__")) {
+ remove_dunder_class = 1;
+ }
+ else if (_PyUnicode_EqualToASCIIString(k, "__conditional_annotations__")) {
+ remove_dunder_cond_annotations = 1;
+ }
+ else {
+ remove_dunder_classdict = 1;
+ }
}
if (!existing) {
// name does not exist in scope, copy from comprehension
@@ -823,6 +837,12 @@ inline_comprehension(PySTEntryObject *ste, PySTEntryObject *comp,
if (remove_dunder_class && PyDict_DelItemString(comp->ste_symbols, "__class__") < 0) {
return 0;
}
+ if (remove_dunder_classdict && PyDict_DelItemString(comp->ste_symbols, "__classdict__") < 0) {
+ return 0;
+ }
+ if (remove_dunder_cond_annotations && PyDict_DelItemString(comp->ste_symbols, "__conditional_annotations__") < 0) {
+ return 0;
+ }
return 1;
}