bpo-15088 : Remove PyGen_NeedsFinalizing() (GH-15702)
authorJoannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
Fri, 6 Sep 2019 15:41:38 +0000 (12:41 -0300)
committerVictor Stinner <vstinner@redhat.com>
Fri, 6 Sep 2019 15:41:38 +0000 (17:41 +0200)
Remove PyGen_NeedsFinalizing(): it was not
documented, tested or used anywhere within CPython after
the implementation of PEP 442.

Doc/whatsnew/3.9.rst
Include/genobject.h
Misc/NEWS.d/next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst [new file with mode: 0644]
Objects/genobject.c
Python/ceval.c

index 756690d93793e6b002f5058d62153d074295ea41..5670cb59f481b2d5740c9210ba51bcc723834baf 100644 (file)
@@ -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
 =====================
index 6755963f332f767111af93cdd0e7ff79aa6b02c5..3b3b68b56b9021da6efead0b412b2115ccbb8554 100644 (file)
@@ -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 (file)
index 0000000..8a27afc
--- /dev/null
@@ -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
index 5e0bfa4f43de5b8060c587eb9877a67ea2a407f0..9f490b4e2e483dd22e799b132142acb9cf0619c1 100644 (file)
@@ -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 {
index 7a3f42c3437f20431e52ac6cd9d5f612dc319dc7..f9e03b3097f0b718a693b2db637b07e55b88a1ce 100644 (file)
@@ -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();