Skip to content

Commit

Permalink
bpo-15088 : Remove PyGen_NeedsFinalizing() (GH-15702)
Browse files Browse the repository at this point in the history
Remove PyGen_NeedsFinalizing(): it was not
documented, tested or used anywhere within CPython after
the implementation of PEP 442.
  • Loading branch information
nanjekyejoannah authored and vstinner committed Sep 6, 2019
1 parent d8c93aa commit 74b662c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 22 deletions.
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.9.rst
Expand Up @@ -222,6 +222,11 @@ Removed
* ``PyThreadState_DeleteCurrent()`` has been removed. It was not documented.
(Contributed by Joannah Nanjekye in :issue:`37878`.)

* The C function ``PyGen_NeedsFinalizing`` has been removed. It was not
documented, tested or used anywhere within CPython after the implementation
of :pep:`442`. Patch by Joannah Nanjekye.
(Contributed by Joannah Nanjekye in :issue:`15088`)


Porting to Python 3.9
=====================
Expand Down
1 change: 0 additions & 1 deletion Include/genobject.h
Expand Up @@ -43,7 +43,6 @@ PyAPI_DATA(PyTypeObject) 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_SetStopIterationValue(PyObject *);
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
PyAPI_FUNC(PyObject *) _PyGen_Send(PyGenObject *, PyObject *);
Expand Down
@@ -0,0 +1,4 @@
The C function ``PyGen_NeedsFinalizing`` has been removed. It was not
documented, tested or used anywhere within CPython after the implementation
of :pep:`442`. Patch by Joannah Nanjekye.
(Patch by Joannah Nanjekye)
16 changes: 0 additions & 16 deletions Objects/genobject.c
Expand Up @@ -819,22 +819,6 @@ PyGen_New(PyFrameObject *f)
return gen_new_with_qualname(&PyGen_Type, f, NULL, NULL);
}

int
PyGen_NeedsFinalizing(PyGenObject *gen)
{
PyFrameObject *f = gen->gi_frame;

if (f == NULL || f->f_stacktop == NULL)
return 0; /* no frame or empty blockstack == no finalization */

/* Any (exception-handling) block type requires cleanup. */
if (f->f_iblock > 0)
return 1;

/* No blocks, it's safe to skip finalization. */
return 0;
}

/* Coroutine Object */

typedef struct {
Expand Down
5 changes: 0 additions & 5 deletions Python/ceval.c
Expand Up @@ -3227,11 +3227,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
}

case TARGET(SETUP_FINALLY): {
/* NOTE: If you add any new block-setup opcodes that
are not try/except/finally handlers, you may need
to update the PyGen_NeedsFinalizing() function.
*/

PyFrame_BlockSetup(f, SETUP_FINALLY, INSTR_OFFSET() + oparg,
STACK_LEVEL());
DISPATCH();
Expand Down

0 comments on commit 74b662c

Please sign in to comment.