[Python-checkins] bpo-15088 : Remove PyGen_NeedsFinalizing() (GH-15702)

Victor Stinner webhook-mailer at python.org
Fri Sep 6 11:42:02 EDT 2019


https://github.com/python/cpython/commit/74b662cf202753d224d82d5503974cce881f7436
commit: 74b662cf202753d224d82d5503974cce881f7436
branch: master
author: Joannah Nanjekye <33177550+nanjekyejoannah at users.noreply.github.com>
committer: Victor Stinner <vstinner at redhat.com>
date: 2019-09-06T17:41:38+02:00
summary:

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.

files:
A Misc/NEWS.d/next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst
M Doc/whatsnew/3.9.rst
M Include/genobject.h
M Objects/genobject.c
M Python/ceval.c

diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index 756690d93793..5670cb59f481 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 6755963f332f..3b3b68b56b90 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 000000000000..8a27afc9678a
--- /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 5e0bfa4f43de..9f490b4e2e48 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 7a3f42c3437f..f9e03b3097f0 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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();



More information about the Python-checkins mailing list