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.

Author vstinner
Recipients nascheme, vstinner
Date 2020-02-07.01:02:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Py_TYPE() is commonly used to render the type name in an error message. Example:

             "cannot convert '%.200s' object to bytearray",

This code has multiple issues:

* It truncates type name to 200 characters: there is no Python exception, not even a marker to indicate that the string has been truncated
* It's only the short name: the qualified name (tp_qualname) would be more helpful. The best would be to generate the fully qualified name: module + qualname.
* Py_TYPE() returns a borrowed reference which is causing multiple issues:

In September 2018, I created bpo-34595: "PyUnicode_FromFormat(): add %T format for an object type name". But there was disagreement, so I rejected my change.

I started "bpo-34595: How to format a type name?" thread on python-dev:

I didn't continue this work (until now), since it wasn't my priority.
Date User Action Args
2020-02-07 01:02:14vstinnersetrecipients: + vstinner, nascheme
2020-02-07 01:02:14vstinnersetmessageid: <>
2020-02-07 01:02:14vstinnerlinkissue39573 messages
2020-02-07 01:02:13vstinnercreate