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.
Created on 2011年11月21日 20:53 by pitrou, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| baec10c6dcd4.diff | pitrou, 2011年11月21日 20:55 | review | ||
| 942ba1e2f8c1.diff | pitrou, 2011年11月23日 23:28 | review | ||
| Repositories containing patches | |||
|---|---|---|---|
| http://hg.python.org/features/pep-3155#pep-3155 | |||
| Messages (18) | |||
|---|---|---|---|
| msg148087 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年11月21日 20:53 | |
Here is an issue covering PEP 3155 implementation. Hopefully a "review" link will appear in front of the hg repo URL. |
|||
| msg148090 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年11月21日 21:18 | |
I just have a comment: "XXX" should be replaced in "Python 3.3a0 3200 XXX". |
|||
| msg148121 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年11月22日 15:25 | |
Nothing to say; waiting for a doc update. |
|||
| msg148214 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年11月23日 23:29 | |
New patch addressing Benjamin's and Victor's comments. |
|||
| msg148217 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年11月24日 00:13 | |
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. |
|||
| msg148219 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年11月24日 00:28 | |
> 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. __getattr__ / PyObject_GetAttr. |
|||
| msg148254 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年11月24日 14:07 | |
Doc patch looks good. |
|||
| msg148289 - (view) | Author: Richard Oudkerk (sbt) * (Python committer) | Date: 2011年11月24日 21:50 | |
Is it intended that pickle will use __qualname__? |
|||
| msg148290 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2011年11月24日 22:49 | |
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. |
|||
| msg148294 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年11月25日 00:33 | |
> Is it intended that pickle will use __qualname__? That's part of the plan for PEP 3154, yes. |
|||
| msg148345 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2011年11月25日 18:03 | |
New changeset e1dbc72bd97f by Antoine Pitrou in branch 'default': PEP 3155 / issue #13448: Qualified name for classes and functions. http://hg.python.org/cpython/rev/e1dbc72bd97f |
|||
| msg148347 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年11月25日 18:44 | |
Now committed together with docs and a what's new entry. Thanks for the reviews! |
|||
| msg148368 - (view) | Author: Richard Oudkerk (sbt) * (Python committer) | Date: 2011年11月25日 23:52 | |
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.
|
|||
| msg148372 - (view) | Author: Richard Oudkerk (sbt) * (Python committer) | Date: 2011年11月26日 00:22 | |
For builtin_function_or_method it seems obj.__qualname__ should be obj.__self__.__qualname__ + '.' + obj.__name__ |
|||
| msg148375 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年11月26日 00:31 | |
> 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? 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. > 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. I am a bit surprised that this works at all. Apparently attribute lookups are redirected to the underlying function. |
|||
| msg149203 - (view) | Author: Jesús Cea Avión (jcea) * (Python committer) | Date: 2011年12月11日 01:54 | |
I am evaluating the use of "__qualname__" in my dtrace probes (issue #13405) and I see things like this: """ >>> def a() : ... class b() : ... pass ... return b() ... >>> c=a() >>> c <__main__.a.<locals>.b object at 0xfe37f3ac> >>> c.__qualname__ Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'b' object has no attribute '__qualname__' >>> a <function a at 0xfe3800bc> >>> a.__qualname__ 'a' """ I guess the class should have a __qualname__ too, haven't it? |
|||
| msg149205 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2011年12月11日 02:18 | |
No, it's only class objects that have __name__ and __qualname__, not class instances. |
|||
| msg156235 - (view) | Author: Matt Joiner (anacrolix) | Date: 2012年03月18日 07:47 | |
Doc/library/dis.rst wasn't updated for the extra pop introduced to MAKE_CLOSURE opcode. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:24 | admin | set | github: 57657 |
| 2012年03月18日 07:47:23 | anacrolix | set | nosy:
+ anacrolix messages: + msg156235 |
| 2011年12月11日 02:18:14 | ncoghlan | set | messages: + msg149205 |
| 2011年12月11日 01:54:19 | jcea | set | messages: + msg149203 |
| 2011年12月11日 01:16:44 | jcea | set | nosy:
+ jcea |
| 2011年11月26日 00:31:01 | pitrou | set | messages: + msg148375 |
| 2011年11月26日 00:22:02 | sbt | set | messages: + msg148372 |
| 2011年11月25日 23:52:10 | sbt | set | messages: + msg148368 |
| 2011年11月25日 18:44:16 | pitrou | set | status: open -> closed resolution: fixed messages: + msg148347 stage: patch review -> resolved |
| 2011年11月25日 18:03:54 | python-dev | set | nosy:
+ python-dev messages: + msg148345 |
| 2011年11月25日 00:33:54 | pitrou | set | messages: + msg148294 |
| 2011年11月24日 22:49:07 | ncoghlan | set | messages: + msg148290 |
| 2011年11月24日 21:50:46 | sbt | set | nosy:
+ sbt messages: + msg148289 |
| 2011年11月24日 15:55:41 | eric.araujo | link | issue13224 dependencies |
| 2011年11月24日 14:07:15 | eric.araujo | set | messages: + msg148254 |
| 2011年11月24日 14:06:42 | eric.araujo | set | messages: - msg148252 |
| 2011年11月24日 14:06:39 | eric.araujo | set | messages: - msg148253 |
| 2011年11月24日 14:05:30 | eric.araujo | set | messages: + msg148253 |
| 2011年11月24日 14:04:32 | eric.araujo | set | messages: + msg148252 |
| 2011年11月24日 00:28:09 | pitrou | set | messages: + msg148219 |
| 2011年11月24日 00:13:40 | vstinner | set | messages: + msg148217 |
| 2011年11月23日 23:29:39 | pitrou | set | messages: + msg148214 |
| 2011年11月23日 23:28:04 | pitrou | set | files: + 942ba1e2f8c1.diff |
| 2011年11月22日 15:25:32 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg148121 |
| 2011年11月21日 21:18:25 | vstinner | set | nosy:
+ vstinner messages: + msg148090 |
| 2011年11月21日 20:55:15 | pitrou | set | files:
+ baec10c6dcd4.diff keywords: + patch |
| 2011年11月21日 20:53:50 | pitrou | create | |