diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-06-16 13:59:28 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-06-16 13:59:28 (GMT) |
commit | 40ee30181f7f7c71d6b49ceef35b5d3d20b88a6d (patch) | |
tree | 4f6813c9aff51c1f467504698456c7c4a1c33244 /Include/genobject.h | |
parent | 26171993fe629c614e62c7aef1196c0f53a30d85 (diff) | |
download | cpython-40ee30181f7f7c71d6b49ceef35b5d3d20b88a6d.zip cpython-40ee30181f7f7c71d6b49ceef35b5d3d20b88a6d.tar.gz cpython-40ee30181f7f7c71d6b49ceef35b5d3d20b88a6d.tar.bz2 |
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.
Diffstat (limited to 'Include/genobject.h')
-rw-r--r-- | Include/genobject.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Include/genobject.h b/Include/genobject.h index 65f1ecf..23571e6 100644 --- a/Include/genobject.h +++ b/Include/genobject.h @@ -25,6 +25,12 @@ typedef struct { /* List of weak reference. */ PyObject *gi_weakreflist; + + /* Name of the generator. */ + PyObject *gi_name; + + /* Qualified name of the generator. */ + PyObject *gi_qualname; } PyGenObject; PyAPI_DATA(PyTypeObject) PyGen_Type; @@ -33,6 +39,8 @@ PyAPI_DATA(PyTypeObject) PyGen_Type; #define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); +PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(struct _frame *, + PyObject *name, PyObject *qualname); PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **); PyObject *_PyGen_Send(PyGenObject *, PyObject *); |