Skip to content

Commit 57ebf1e

Browse files
nanjekyejoannahlisroach
authored andcommitted
bpo-15088 : Remove PyGen_NeedsFinalizing() (pythonGH-15702)
Remove PyGen_NeedsFinalizing(): it was not documented, tested or used anywhere within CPython after the implementation of PEP 442.
1 parent 17139ed commit 57ebf1e

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

Doc/whatsnew/3.9.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ Removed
222222
* ``PyThreadState_DeleteCurrent()`` has been removed. It was not documented.
223223
(Contributed by Joannah Nanjekye in :issue:`37878`.)
224224

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

226231
Porting to Python 3.9
227232
=====================

Include/genobject.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ PyAPI_DATA(PyTypeObject) PyGen_Type;
4343
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
4444
PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(struct _frame *,
4545
PyObject *name, PyObject *qualname);
46-
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
4746
PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
4847
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
4948
PyAPI_FUNC(PyObject *) _PyGen_Send(PyGenObject *, PyObject *);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The C function ``PyGen_NeedsFinalizing`` has been removed. It was not
2+
documented, tested or used anywhere within CPython after the implementation
3+
of :pep:`442`. Patch by Joannah Nanjekye.
4+
(Patch by Joannah Nanjekye)

Objects/genobject.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -819,22 +819,6 @@ PyGen_New(PyFrameObject *f)
819819
return gen_new_with_qualname(&PyGen_Type, f, NULL, NULL);
820820
}
821821

822-
int
823-
PyGen_NeedsFinalizing(PyGenObject *gen)
824-
{
825-
PyFrameObject *f = gen->gi_frame;
826-
827-
if (f == NULL || f->f_stacktop == NULL)
828-
return 0; /* no frame or empty blockstack == no finalization */
829-
830-
/* Any (exception-handling) block type requires cleanup. */
831-
if (f->f_iblock > 0)
832-
return 1;
833-
834-
/* No blocks, it's safe to skip finalization. */
835-
return 0;
836-
}
837-
838822
/* Coroutine Object */
839823

840824
typedef struct {

Python/ceval.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,11 +3227,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
32273227
}
32283228

32293229
case TARGET(SETUP_FINALLY): {
3230-
/* NOTE: If you add any new block-setup opcodes that
3231-
are not try/except/finally handlers, you may need
3232-
to update the PyGen_NeedsFinalizing() function.
3233-
*/
3234-
32353230
PyFrame_BlockSetup(f, SETUP_FINALLY, INSTR_OFFSET() + oparg,
32363231
STACK_LEVEL());
32373232
DISPATCH();

0 commit comments

Comments
 (0)