You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why an upper P in "PyFunction_NewWithQualName"? If you use an upper P, it should use an underscore in Python: __qual_name__ to be consistent. So I suggest to change the C name :-) PyFunction_NewWithQualname or PyFunction_NewWithQualifiedName. I don't have a preference between these two choices.
Yes, but that can be a separate patch - step 1 is to make the attribute available, then relevant modules can subsequently be updated to use it as appropriate.
Activity
pitrou commentedon Nov 21, 2011
Here is an issue covering PEP-3155 implementation. Hopefully a "review" link will appear in front of the hg repo URL.
vstinner commentedon Nov 21, 2011
I just have a comment: "XXX" should be replaced in "Python 3.3a0 3200 XXX".
merwok commentedon Nov 22, 2011
Nothing to say; waiting for a doc update.
pitrou commentedon Nov 23, 2011
New patch addressing Benjamin's and Victor's comments.
vstinner commentedon Nov 24, 2011
Ah, PyFunction_NewWithQualName is now public.
Why an upper P in "PyFunction_NewWithQualName"? If you use an upper P, it should use an underscore in Python: __qual_name__ to be consistent. So I suggest to change the C name :-) PyFunction_NewWithQualname or PyFunction_NewWithQualifiedName. I don't have a preference between these two choices.
pitrou commentedon Nov 24, 2011
__getattr__ / PyObject_GetAttr.
merwok commentedon Nov 24, 2011
Doc patch looks good.
sbt commentedon Nov 24, 2011
Is it intended that pickle will use __qualname__?
ncoghlan commentedon Nov 24, 2011
Yes, but that can be a separate patch - step 1 is to make the attribute available, then relevant modules can subsequently be updated to use it as appropriate.
pitrou commentedon Nov 25, 2011
That's part of the plan for PEP-3154, yes.
python-dev commentedon Nov 25, 2011
New changeset e1dbc72bd97f by Antoine Pitrou in branch 'default':
PEP-3155 / issue bpo-13448: Qualified name for classes and functions.
http://hg.python.org/cpython/rev/e1dbc72bd97f
pitrou commentedon Nov 25, 2011
Now committed together with docs and a what's new entry. Thanks for the reviews!
sbt commentedon Nov 25, 2011
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__:
Maybe this should be 'A().f' instead.
sbt commentedon Nov 26, 2011
For builtin_function_or_method it seems obj.__qualname__ should be
obj.__self__.__qualname__ + '.' + obj.__name__
pitrou commentedon Nov 26, 2011
Indeed, they were overlooked. Due to the way they are instantiated,
though, it would be quite a bit harder to devise a __qualname__ for
them.
I am a bit surprised that this works at all. Apparently attribute
lookups are redirected to the underlying function.
jcea commentedon Dec 11, 2011
I am evaluating the use of "__qualname__" in my dtrace probes (issue bpo-13405) and I see things like this:
I guess the class should have a __qualname__ too, haven't it?
ncoghlan commentedon Dec 11, 2011
No, it's only class objects that have __name__ and __qualname__, not class instances.
anacrolix commentedon Mar 18, 2012
Doc/library/dis.rst wasn't updated for the extra pop introduced to MAKE_CLOSURE opcode.