Skip to content

bpo-15088 : Remove PyGen_NeedsFinalizing() #15702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 6, 2019
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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