mirror of
https://github.com/python/cpython.git
synced 2026-04-20 02:40:59 +00:00
gh-137814: Fix __qualname__ of __annotate__ (#137842)
This commit is contained in:
parent
54607eec34
commit
5b8cd314e2
6 changed files with 38 additions and 1 deletions
|
|
@ -297,6 +297,19 @@ compiler_set_qualname(compiler *c)
|
|||
base = Py_NewRef(parent->u_metadata.u_qualname);
|
||||
}
|
||||
}
|
||||
if (u->u_ste->ste_function_name != NULL) {
|
||||
PyObject *tmp = base;
|
||||
base = PyUnicode_FromFormat("%U.%U",
|
||||
base,
|
||||
u->u_ste->ste_function_name);
|
||||
Py_DECREF(tmp);
|
||||
if (base == NULL) {
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (u->u_ste->ste_function_name != NULL) {
|
||||
base = Py_NewRef(u->u_ste->ste_function_name);
|
||||
}
|
||||
|
||||
if (base != NULL) {
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block,
|
|||
ste->ste_id = k; /* ste owns reference to k */
|
||||
|
||||
ste->ste_name = Py_NewRef(name);
|
||||
ste->ste_function_name = NULL;
|
||||
|
||||
ste->ste_symbols = NULL;
|
||||
ste->ste_varnames = NULL;
|
||||
|
|
@ -186,6 +187,7 @@ ste_dealloc(PyObject *op)
|
|||
ste->ste_table = NULL;
|
||||
Py_XDECREF(ste->ste_id);
|
||||
Py_XDECREF(ste->ste_name);
|
||||
Py_XDECREF(ste->ste_function_name);
|
||||
Py_XDECREF(ste->ste_symbols);
|
||||
Py_XDECREF(ste->ste_varnames);
|
||||
Py_XDECREF(ste->ste_children);
|
||||
|
|
@ -2918,6 +2920,7 @@ symtable_visit_annotations(struct symtable *st, stmt_ty o, arguments_ty a, expr_
|
|||
(void *)a, LOCATION(o))) {
|
||||
return 0;
|
||||
}
|
||||
Py_XSETREF(st->st_cur->ste_function_name, Py_NewRef(function_ste->ste_name));
|
||||
if (is_in_class || current_type == ClassBlock) {
|
||||
st->st_cur->ste_can_see_class_scope = 1;
|
||||
if (!symtable_add_def(st, &_Py_ID(__classdict__), USE, LOCATION(o))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue