Issue #21205: Add a new `__qualname__` attribute to generator, the qualified

name, and use it in the representation of a generator (``repr(gen)``). The
default name of the generator (``__name__`` attribute) is now get from the
function instead of the code. Use ``gen.gi_code.co_name`` to get the name of
the code.
This commit is contained in:
Victor Stinner 2014-06-16 15:59:28 +02:00
parent 26171993fe
commit 40ee30181f
7 changed files with 171 additions and 24 deletions

View file

@ -159,6 +159,16 @@ attributes:
| | | arguments and local |
| | | variables |
+-----------+-----------------+---------------------------+
| generator | __name__ | name |
+-----------+-----------------+---------------------------+
| | __qualname__ | qualified name |
+-----------+-----------------+---------------------------+
| | gi_frame | frame |
+-----------+-----------------+---------------------------+
| | gi_running | is the generator running? |
+-----------+-----------------+---------------------------+
| | gi_code | code |
+-----------+-----------------+---------------------------+
| builtin | __doc__ | documentation string |
+-----------+-----------------+---------------------------+
| | __name__ | original name of this |
@ -169,6 +179,10 @@ attributes:
| | | ``None`` |
+-----------+-----------------+---------------------------+
.. versionchanged:: 3.5
Add ``__qualname__`` attribute to generators.
.. function:: getmembers(object[, predicate])