Message324876
> 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. |
|
Date |
User |
Action |
Args |
2018-09-09 08:33:14 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, vstinner, eric.smith |
2018-09-09 08:33:14 | serhiy.storchaka | set | messageid: <1536481994.8.0.56676864532.issue34595@psf.upfronthosting.co.za> |
2018-09-09 08:33:14 | serhiy.storchaka | link | issue34595 messages |
2018-09-09 08:33:14 | serhiy.storchaka | create | |
|