[Python-Dev] Issue #21205: add qualname to generators (original) (raw)
Yury Selivanov yselivanov.ml at gmail.com
Thu Jun 12 18:34:47 CEST 2014
- Previous message: [Python-Dev] Issue #21205: add __qualname__ to generators
- Next message: [Python-Dev] subprocess shell=True on Windows doesn't escape ^ character
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello Victor,
On 2014-06-11, 10:28 AM, Victor Stinner wrote:
Hi,
I'm working on asyncio and it's difficult to debug code because @asyncio.coroutine decorator removes the name of the function if the function is not a generator (if it doesn't use yield from). I propose to add new giname and giqualname fields to the C structure PyGenObject, add a new qualname (= giqualname) attribute to the Python API of generator, and change how the default value of name (= giname) of generators. Instead of getting the name from the code object, I propose to get the name from the function (if the generator was created from a function). So if the function name was modified, you get the new name instead of getting the name from the code object (as done in Python 3.4). I also propose to display the qualified name in repr(generator) instead of the name. All these changes should make my life easier to debug asyncio, but it should help any project using generators. Issues describing the problem, I attached a patch implementing my ideas: http://bugs.python.org/issue21205 Would you be ok with these (minor) incompatible changes?
I'm +1 for your proposal.
This change will indeed make debugging asyncio (and any generator-heavy code) easier. I wouldn't worry too much about compatibility, as the change is fairly minimal, and the feature will only land in 3.5, where people expect new things and are generally OK with slightly updated behaviors.
Yury
By the way, it looks like generator attributes were never documented :-( My patch also adds a basic documentation (at least, it lists all attributes in the documentation of the inspect module). Victor
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/yselivanov.ml%40gmail.com
- Previous message: [Python-Dev] Issue #21205: add __qualname__ to generators
- Next message: [Python-Dev] subprocess shell=True on Windows doesn't escape ^ character
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]