From 74b662cf202753d224d82d5503974cce881f7436 Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com> Date: Fri, 6 Sep 2019 12:41:38 -0300 Subject: [PATCH] bpo-15088 : Remove PyGen_NeedsFinalizing() (GH-15702) Remove PyGen_NeedsFinalizing(): it was not documented, tested or used anywhere within CPython after the implementation of PEP 442. --- Doc/whatsnew/3.9.rst | 5 +++++ Include/genobject.h | 1 - .../2019-09-05-14-17-21.bpo-15088.plt8Em.rst | 4 ++++ Objects/genobject.c | 16 ---------------- Python/ceval.c | 5 ----- 5 files changed, 9 insertions(+), 22 deletions(-) create mode 100644 Misc/NEWS.d/next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 756690d937..5670cb59f4 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -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 ===================== diff --git a/Include/genobject.h b/Include/genobject.h index 6755963f33..3b3b68b56b 100644 --- a/Include/genobject.h +++ b/Include/genobject.h @@ -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 *); diff --git a/Misc/NEWS.d/next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst b/Misc/NEWS.d/next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst new file mode 100644 index 0000000000..8a27afc967 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst @@ -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) \ No newline at end of file diff --git a/Objects/genobject.c b/Objects/genobject.c index 5e0bfa4f43..9f490b4e2e 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -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 { diff --git a/Python/ceval.c b/Python/ceval.c index 7a3f42c343..f9e03b3097 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3227,11 +3227,6 @@ main_loop: } 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(); -- 2.40.0