Skip to content
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
fix bug and refleak
  • Loading branch information
JelleZijlstra committed Aug 16, 2025
commit e6f1adf92d427cc73ad568d5b8ca134479697bc5
5 changes: 4 additions & 1 deletion Lib/test/test_type_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,9 @@ def test_complex_comprehension_inlining_exec(self):

def test_annotate_qualname(self):
code = """
def f() -> None: pass
def f() -> None:
def nested() -> None: pass
return nested
class Outer:
x: int
def method(self, x: int):
Expand All @@ -848,4 +850,5 @@ def method(self, x: int):
method = ns["Outer"].method
self.assertEqual(method.__annotate__.__qualname__, "Outer.method.__annotate__")
self.assertEqual(ns["f"].__annotate__.__qualname__, "f.__annotate__")
self.assertEqual(ns["f"]().__annotate__.__qualname__, "f.<locals>.nested.__annotate__")
self.assertEqual(ns["Outer"].__annotate__.__qualname__, "Outer.__annotate__")
4 changes: 3 additions & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,11 @@ compiler_set_qualname(compiler *c)
}
}
if (u->u_ste->ste_function_name != NULL) {
PyObject *tmp = base;
base = PyUnicode_FromFormat("%U.%U",
parent->u_metadata.u_qualname,
base,
u->u_ste->ste_function_name);
Py_DECREF(tmp);
if (base == NULL) {
return ERROR;
}
Expand Down
Loading