[New-bugs-announce] [issue13672] Add co_qualname attribute in code objects

Arfrever Frehtes Taifersar Arahesis report at bugs.python.org
Wed Dec 28 20:20:00 CET 2011

New submission from Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA at GMail.Com>:

PEP 3155 added qualified name as __qualname__ attribute in classes and functions. It would be useful if qualified name was also available as co_qualname attribute of code objects.

>>> import sys
>>> class A:
...     def f1():
...         return B.f2()
>>> class B:
...     def f2():
...         return sys._getframe(1)
>>> A.f1.__name__
>>> A.f1.__qualname__
>>> B.f2.__name__
>>> B.f2.__qualname__
>>> frame = A.f1()
>>> frame
<frame object at 0x7f9c1adca3a0>
>>> frame.f_code
<code object f1 at 0x7f9c1ae4be40, file "<stdin>", line 2>
>>> frame.f_code.co_name
>>> frame.f_code.co_qualname
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'code' object has no attribute 'co_qualname'

Suggested behavior:
>>> frame.f_code.co_qualname

components: Interpreter Core
messages: 150312
nosy: Arfrever, pitrou
priority: normal
severity: normal
status: open
title: Add co_qualname attribute in code objects
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list