This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: type.__qualname__ ignores module name in tp_name for static types
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.11, Python 3.10, Python 3.9
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ronaldoussoren, serhiy.storchaka
Priority: normal Keywords:

Created on 2022-03-05 10:41 by ronaldoussoren, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg414574 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2022-03-05 10:41
In a static type when the "tp_name" is set to a fully qualified name (such as "my.package.TypeName") the "__qualname__" returns the unqualified name ("TypeName") instead of the fully qualified name.

The type's ``__name__`` and ``__module__`` have the expected value.

This is IMHO a bug in the implementation of type_qualname in Objects/typeobject.c.

Note that setting ``__qualname__`` in the types's ``__dict__`` doesn't work, that value is ignored.
msg414588 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2022-03-05 17:05
What do you expect?

The full qualified name of the object is __module__ + '.' + __qualname__.
msg414594 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2022-03-05 19:56
You're right. I was sure that __qualname__ included the module name, but PEP 3155 is clear about actual semantics.

Sorry about the noise.
Date User Action Args
2022-04-11 14:59:57adminsetgithub: 91084
2022-03-05 19:56:22ronaldoussorensetstatus: open -> closed
resolution: not a bug
messages: + msg414594

stage: test needed -> resolved
2022-03-05 17:05:27serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg414588
2022-03-05 10:41:07ronaldoussorencreate