diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-10-19 20:01:13 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-10-19 20:01:13 (GMT) |
commit | 3d9e481ece356d805ee5658600ef2888e35a5609 (patch) | |
tree | f47e7215f5dab6c99da5b0e23872f24a00176137 /Lib | |
parent | 358667370346594c0383f1bfa09e0d650fa8832d (diff) | |
download | cpython-3d9e481ece356d805ee5658600ef2888e35a5609.zip cpython-3d9e481ece356d805ee5658600ef2888e35a5609.tar.gz cpython-3d9e481ece356d805ee5658600ef2888e35a5609.tar.bz2 |
give explicitly global functions and classes a global __qualname__ (closes #19301)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 3 | ||||
-rw-r--r-- | Lib/test/test_descr.py | 5 | ||||
-rw-r--r-- | Lib/test/test_funcattrs.py | 4 |
3 files changed, 11 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 880a9ec..e8eeea1 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -369,12 +369,13 @@ def _call_with_frames_removed(f, *args, **kwds): # free vars) # Python 3.4a1 3270 (various tweaks to the __class__ closure) # Python 3.4a1 3280 (remove implicit class argument) +# Python 3.4a4 3290 (changes to __qualname__ computation) # # MAGIC must change whenever the bytecode emitted by the compiler may no # longer be understood by older implementations of the eval loop (usually # due to the addition of new opcodes). -MAGIC_NUMBER = (3280).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3290).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index f0d6d1c..90efb27 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4517,6 +4517,11 @@ order (MRO) for bases """ self.assertRaises(TypeError, type.__dict__['__qualname__'].__set__, str, 'Oink') + global Y + class Y: + pass + self.assertEqual(Y.__qualname__, 'Y') + def test_qualname_dict(self): ns = {'__qualname__': 'some.name'} tp = type('Foo', (), ns) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index c8ed830..1d8fa13 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -7,6 +7,9 @@ def global_function(): def inner_function(): class LocalClass: pass + global inner_global_function + def inner_global_function(): + pass return LocalClass return lambda: inner_function @@ -116,6 +119,7 @@ class FunctionPropertiesTest(FuncAttrsTest): 'global_function.<locals>.inner_function') self.assertEqual(global_function()()().__qualname__, 'global_function.<locals>.inner_function.<locals>.LocalClass') + self.assertEqual(inner_global_function.__qualname__, 'inner_global_function') self.b.__qualname__ = 'c' self.assertEqual(self.b.__qualname__, 'c') self.b.__qualname__ = 'd' |