From 46c15d6ca665da149523ea66b8f2c49a404c52d4 Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye Date: Thu, 5 Sep 2019 13:58:29 +0000 Subject: [PATCH 1/8] Remove PyGen_NeedsFinalizing() --- Doc/whatsnew/3.9.rst | 4 ++++ Include/genobject.h | 2 +- Objects/genobject.c | 2 +- Python/ceval.c | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 009a66adff7d58..647426a9134bd5 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -219,6 +219,10 @@ Removed standard :class:`bytes` objects are always used. (Contributed by Jon Janzen in :issue:`36409`.) +* The C function ``PyGen_NeedsFinalizing`` has been removed. It was documented + and not used anywhere in the source code. + (Contributed by Joannah Nanjekye in :issue:`15088`) + Porting to Python 3.9 ===================== diff --git a/Include/genobject.h b/Include/genobject.h index 6755963f332f76..3cd9f04a0eca68 100644 --- a/Include/genobject.h +++ b/Include/genobject.h @@ -43,7 +43,7 @@ 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_NeedsFinalizing(PyGenObject *); PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *); PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **); PyAPI_FUNC(PyObject *) _PyGen_Send(PyGenObject *, PyObject *); diff --git a/Objects/genobject.c b/Objects/genobject.c index 5e0bfa4f43de5b..c256b26d870356 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -820,7 +820,7 @@ PyGen_New(PyFrameObject *f) } int -PyGen_NeedsFinalizing(PyGenObject *gen) +_PyGen_NeedsFinalizing(PyGenObject *gen) { PyFrameObject *f = gen->gi_frame; diff --git a/Python/ceval.c b/Python/ceval.c index 7a3f42c3437f20..1a6a6583ba814e 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3229,7 +3229,7 @@ _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. + to update the _PyGen_NeedsFinalizing() function. */ PyFrame_BlockSetup(f, SETUP_FINALLY, INSTR_OFFSET() + oparg, From 4a0d82fab4e7bbd6819973cef40b2970fb41822f Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2019 14:17:26 +0000 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Misc/NEWS.d/next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst 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 00000000000000..ee6bf248ae74d5 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst @@ -0,0 +1 @@ +Remove undocumented and unused `PyGen_NeedsFinalizing()`. \ No newline at end of file From e9e0347239ae605ff7ea495a6b10bf060d60d14c Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye Date: Thu, 5 Sep 2019 14:21:50 +0000 Subject: [PATCH 3/8] Update news --- Doc/whatsnew/3.9.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 647426a9134bd5..5a905e2dcadc5b 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -219,7 +219,7 @@ Removed standard :class:`bytes` objects are always used. (Contributed by Jon Janzen in :issue:`36409`.) -* The C function ``PyGen_NeedsFinalizing`` has been removed. It was documented +* The C function ``PyGen_NeedsFinalizing`` has been removed. It was not documented and not used anywhere in the source code. (Contributed by Joannah Nanjekye in :issue:`15088`) From 775e796a094897d744cd9c574f6bb58400ab25af Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye Date: Thu, 5 Sep 2019 15:16:10 +0000 Subject: [PATCH 4/8] Deprecate PyGen_NeedsFinalizing() --- Doc/whatsnew/3.9.rst | 5 +++-- Include/genobject.h | 2 +- .../next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst | 5 ++++- Objects/genobject.c | 2 +- Python/ceval.c | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 5a905e2dcadc5b..1942e65c5e00f2 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -219,8 +219,9 @@ Removed standard :class:`bytes` objects are always used. (Contributed by Jon Janzen in :issue:`36409`.) -* The C function ``PyGen_NeedsFinalizing`` has been removed. It was not documented - and not used anywhere in the source code. +* The C function ``PyGen_NeedsFinalizing`` has been deprecated. It was not + documented anor even used wnywhere in the codebase. It will therefore be + removed in the next release. (Contributed by Joannah Nanjekye in :issue:`15088`) diff --git a/Include/genobject.h b/Include/genobject.h index 3cd9f04a0eca68..ea50922112d3a5 100644 --- a/Include/genobject.h +++ b/Include/genobject.h @@ -43,7 +43,7 @@ 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 *); +Py_DEPRECATED(3.9) 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 index ee6bf248ae74d5..5df6146619b3ce 100644 --- 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 @@ -1 +1,4 @@ -Remove undocumented and unused `PyGen_NeedsFinalizing()`. \ No newline at end of file +The C function ``PyGen_NeedsFinalizing`` has been deprecated. It was not +documented anor even used wnywhere in the codebase. It will therefore be +removed in the next release. +(Patch by Joannah Nanjekye) \ No newline at end of file diff --git a/Objects/genobject.c b/Objects/genobject.c index c256b26d870356..5e0bfa4f43de5b 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -820,7 +820,7 @@ PyGen_New(PyFrameObject *f) } int -_PyGen_NeedsFinalizing(PyGenObject *gen) +PyGen_NeedsFinalizing(PyGenObject *gen) { PyFrameObject *f = gen->gi_frame; diff --git a/Python/ceval.c b/Python/ceval.c index 1a6a6583ba814e..7a3f42c3437f20 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3229,7 +3229,7 @@ _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. + to update the PyGen_NeedsFinalizing() function. */ PyFrame_BlockSetup(f, SETUP_FINALLY, INSTR_OFFSET() + oparg, From 6671811fd629460b5eca57ce14a2a9339908c27a Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye Date: Thu, 5 Sep 2019 16:22:45 +0000 Subject: [PATCH 5/8] Remove the C function PyGen_NeedsFinalizing --- Doc/whatsnew/3.9.rst | 6 +++--- Include/genobject.h | 1 - .../2019-09-05-14-17-21.bpo-15088.plt8Em.rst | 6 +++--- Objects/genobject.c | 16 ---------------- Python/ceval.c | 5 ----- 5 files changed, 6 insertions(+), 28 deletions(-) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 1942e65c5e00f2..00f5a09c7b91b5 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -219,9 +219,9 @@ Removed standard :class:`bytes` objects are always used. (Contributed by Jon Janzen in :issue:`36409`.) -* The C function ``PyGen_NeedsFinalizing`` has been deprecated. It was not - documented anor even used wnywhere in the codebase. It will therefore be - removed in the next release. +* The C function ``PyGen_NeedsFinalizing`` has been removed. It was not + documented, tested or even used anywhere in the code base after + after :pep:`442` implementation made it useless. (Contributed by Joannah Nanjekye in :issue:`15088`) diff --git a/Include/genobject.h b/Include/genobject.h index ea50922112d3a5..3b3b68b56b9021 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); -Py_DEPRECATED(3.9) 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 index 5df6146619b3ce..475a89c21d045f 100644 --- 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 @@ -1,4 +1,4 @@ -The C function ``PyGen_NeedsFinalizing`` has been deprecated. It was not -documented anor even used wnywhere in the codebase. It will therefore be -removed in the next release. +The C function ``PyGen_NeedsFinalizing`` has been removed. It was not +documented, tested or even used anywhere in the code base after +PEP 442 implementation made it useless. (Patch by Joannah Nanjekye) \ No newline at end of file diff --git a/Objects/genobject.c b/Objects/genobject.c index 5e0bfa4f43de5b..9f490b4e2e483d 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 7a3f42c3437f20..f9e03b3097f0b7 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(); From 8186611099005f85a13556ef017626dd23a83d2c Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye Date: Thu, 5 Sep 2019 16:24:51 +0000 Subject: [PATCH 6/8] come clean --- Doc/whatsnew/3.9.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 00f5a09c7b91b5..009a66adff7d58 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -219,11 +219,6 @@ Removed standard :class:`bytes` objects are always used. (Contributed by Jon Janzen in :issue:`36409`.) -* The C function ``PyGen_NeedsFinalizing`` has been removed. It was not - documented, tested or even used anywhere in the code base after - after :pep:`442` implementation made it useless. - (Contributed by Joannah Nanjekye in :issue:`15088`) - Porting to Python 3.9 ===================== From 729b48ed2ab5f9c745f18a6ddb01a26f404e82c2 Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye Date: Thu, 5 Sep 2019 16:26:31 +0000 Subject: [PATCH 7/8] resolve merge conflict --- Doc/whatsnew/3.9.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 756690d93793e6..f6d35393405c5b 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 even used anywhere in the code base after + after :pep:`442` implementation which made it useless. + (Contributed by Joannah Nanjekye in :issue:`15088`) + Porting to Python 3.9 ===================== From 4dd10ac137ebd9714c001bbfc2e3e3ad2af0ffd1 Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye Date: Fri, 6 Sep 2019 13:41:45 +0000 Subject: [PATCH 8/8] Update documentation --- Doc/whatsnew/3.9.rst | 4 ++-- .../next/C API/2019-09-05-14-17-21.bpo-15088.plt8Em.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index f6d35393405c5b..5670cb59f481b2 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -223,8 +223,8 @@ Removed (Contributed by Joannah Nanjekye in :issue:`37878`.) * The C function ``PyGen_NeedsFinalizing`` has been removed. It was not - documented, tested or even used anywhere in the code base after - after :pep:`442` implementation which made it useless. + documented, tested or used anywhere within CPython after the implementation + of :pep:`442`. Patch by Joannah Nanjekye. (Contributed by Joannah Nanjekye in :issue:`15088`) 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 index 475a89c21d045f..8a27afc9678a9b 100644 --- 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 @@ -1,4 +1,4 @@ The C function ``PyGen_NeedsFinalizing`` has been removed. It was not -documented, tested or even used anywhere in the code base after -PEP 442 implementation made it useless. +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