diff --git a/extra_tests/snippets/builtin_type.py b/extra_tests/snippets/builtin_type.py index 820ee366155..abb68f812be 100644 --- a/extra_tests/snippets/builtin_type.py +++ b/extra_tests/snippets/builtin_type.py @@ -1,6 +1,6 @@ import types -from testutils import assert_raises +from testutils import assert_raises # Spec: https://docs.python.org/2/library/types.html print(None) @@ -111,8 +111,6 @@ class D: with assert_raises(TypeError): del int.__qualname__ -from testutils import assert_raises - import platform if platform.python_implementation() == "RustPython": @@ -607,3 +605,24 @@ class A(type): assert "__dict__" not in A.__dict__ + + +# regression tests for: https://github.com/RustPython/RustPython/issues/4505 + + +def foo(): + def inner(): + pass + + +assert foo.__code__.co_names == () + +stmts = """ +import blah + +def foo(): + pass +""" + +code = compile(stmts, "", "exec") +assert code.co_names == ("blah", "foo")