[issue13448] PEP 3155 implementation

sbt report at bugs.python.org
Sat Nov 26 00:52:11 CET 2011


sbt <shibturn at gmail.com> added the comment:

There are some callables which are missing __qualname__:

  method_descriptor
  wrapper_descriptor
  builtin_function_or_method

For the descriptors, at least, obj.__qualname__ should be equivalent to

  obj.__objclass__.__qualname__ + '.' + obj.__name__

Were these overlooked?

  PS C:\Repos\cpython> .\PCbuild\python_d
  Python 3.3.0a0 (default, Nov 25 2011, 22:14:28) [MSC v.1500 32 bit (Intel)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import pickle
  [66213 refs]
  >>> attribs = ('__class__', '__name__', '__qualname__')
  [66220 refs]
  >>> for o in (pickle.Pickler, pickle.Pickler.dump, object.__init__, min):
  ...   print([getattr(o, a, None) for a in attribs])
  ...
  [<class 'type'>, 'Pickler', 'Pickler']
  [<class 'method_descriptor'>, 'dump', None]
  [<class 'wrapper_descriptor'>, '__init__', None]
  [<class 'builtin_function_or_method'>, 'min', None]
  [66265 refs]

Also I notice that bound methods have a misleading __qualname__:

  >>> class A:
  ...   def f(self): pass
  ...
  [66348 refs]
  >>> A().f.__qualname__
  'A.f'

Maybe this should be 'A().f' instead.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13448>
_______________________________________


More information about the Python-bugs-list mailing list