mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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:
parent
26171993fe
commit
40ee30181f
7 changed files with 171 additions and 24 deletions
|
@ -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 *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue