Enhance type name formatting when raising an exception: add %T format in C, and add type.__fullyqualname__

We need API for objects and for types in C, unless you want to keep explicit Py_TYPE() calls. I propose to use # to distinguish these two variations.

For different kinds of names we can use the “size” modifier. Currently l, ll, z, t, j are supported, h and hh can be added if this is not enough. We need the following kinds:

  1. t.__name__
  2. t.__qualname__
  3. t.__module__ + '.' + __qualname__
  4. Same as the previous, but omit the module name if it is “builtins” or “__main__”.

It covers virtually all of current uses.

1 Like