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 serhiy.storchaka
Recipients eric.smith, serhiy.storchaka, vstinner
Date 2018-09-09.08:33:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1536481994.8.0.56676864532.issue34595@psf.upfronthosting.co.za>
In-reply-to
Content
> Ok, I wrote PR 9122 to add %t format and modify %T format:

Nice!

I agree that it is easy to use _PyType_Name() directly. But using _PyType_FullName() instead of tp_name can be cumbersome because it returns a new object and needs error handling.

> Or do you want to add a new formatter to type.__format__() to expose %T at the Python level, f"{type(obj).__module__}.{type(obj).__qualname__}"?

Yes, I think we need a convenient way of formatting fully qualified name that omits the module name for types in the builtins module. It is equivalent to Py_TYPE(obj)->tp_name for extension types which is the most popular way to format a type name in error messages for now.

There are several open issues for inconsistency in error messages for Python and C implementations, because the former use type(obj).__name__ or obj.__class__.__name__, and the latter use Py_TYPE(obj)->tp_name. I hope finally we will fix this.
History
Date User Action Args
2018-09-09 08:33:14serhiy.storchakasetrecipients: + serhiy.storchaka, vstinner, eric.smith
2018-09-09 08:33:14serhiy.storchakasetmessageid: <1536481994.8.0.56676864532.issue34595@psf.upfronthosting.co.za>
2018-09-09 08:33:14serhiy.storchakalinkissue34595 messages
2018-09-09 08:33:14serhiy.storchakacreate