[issue21205] Add a name to Python generators

STINNER Victor report at bugs.python.org
Wed Jun 11 16:19:00 CEST 2014


STINNER Victor added the comment:

gen_qualname.patch: add a new "__qualname__" attribute to generators and change how the name is set: use the name of the function, instead of using the name of the code.

Incompatible changes of this patch:

- repr(generator) now shows the qualified name instead of the name
- generator name comes from the function name which may be different

If the function has a name different than the code (if the function name was changed, for example by @functools.wraps), the generator now gets the name from the function, no more from the code object. IMO it's the expected behaviour, and it's more useful.

I'm writing on email to python-dev to discuss these changes.

----------
keywords: +patch
title: Unable to make decorated generator object to inherit generator function's __name__ -> Add a name to Python generators
Added file: http://bugs.python.org/file35571/gen_qualname.patch

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


More information about the Python-bugs-list mailing list