Skip to content

Commit 2b32466

Browse files
committed
Remove PyObject_CallFinalizer()
1 parent ba44a2e commit 2b32466

File tree

10 files changed

+11
-39
lines changed

10 files changed

+11
-39
lines changed

Doc/data/stable_abi.dat

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/whatsnew/3.15.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,8 +1662,8 @@ New features
16621662

16631663
(Contributed by Victor Stinner in :gh:`141510`.)
16641664

1665-
* Add :c:func:`PyObject_CallFinalizer` and
1666-
:c:func:`PyObject_CallFinalizerFromDealloc` functions to the limited C API.
1665+
* Add :c:func:`PyObject_CallFinalizerFromDealloc` function to the limited C
1666+
API.
16671667
(Contributed by Victor Stinner in :gh:`146063`.)
16681668

16691669
* Add :c:func:`PySys_GetAttr`, :c:func:`PySys_GetAttrString`,

Include/cpython/object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ PyAPI_FUNC(void) PyObject_Dump(PyObject *);
303303
Py_DEPRECATED(3.15) PyAPI_FUNC(PyObject*) _PyObject_GetAttrId(PyObject *, _Py_Identifier *);
304304

305305
PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
306+
PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *);
306307

307308
PyAPI_FUNC(void) PyUnstable_Object_ClearWeakRefsNoCallbacks(PyObject *);
308309

Include/object.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,6 @@ PyAPI_FUNC(int) PyType_Freeze(PyTypeObject *type);
856856
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 15)
857857
PyAPI_FUNC(PyObject *) PyType_GetModuleByToken(PyTypeObject *type,
858858
const void *token);
859-
860-
PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *);
861859
PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *);
862860
#endif
863861

Lib/test/test_capi/test_object.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,6 @@ def test_pyobject_dump(self):
305305
output = self.pyobject_dump(NULL)
306306
self.assertRegex(output, r'<object at .* is freed>')
307307

308-
def test_pyobject_callfinalizer(self):
309-
# Test PyObject_CallFinalizer()
310-
pyobject_callfinalizer = _testlimitedcapi.pyobject_callfinalizer
311-
312-
class Finalizer:
313-
def __init__(self):
314-
self.finalized = False
315-
def __del__(self):
316-
self.finalized = True
317-
318-
obj = Finalizer()
319-
self.assertFalse(obj.finalized)
320-
pyobject_callfinalizer(obj)
321-
self.assertTrue(obj.finalized)
322-
323308

324309
if __name__ == "__main__":
325310
unittest.main()

Lib/test/test_stable_abi_ctypes.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
Add :c:func:`PyObject_CallFinalizer` and
2-
:c:func:`PyObject_CallFinalizerFromDealloc` functions to the limited C API.
1+
Add :c:func:`PyObject_CallFinalizerFromDealloc` function to the limited C API.
32
Patch by Victor Stinner.

Misc/stable_abi.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,5 @@
26922692
# (The definition of 'full-abi' was clarified when this entry was added.)
26932693
struct_abi_kind = 'full-abi'
26942694

2695-
[function.PyObject_CallFinalizer]
2696-
added = '3.15'
26972695
[function.PyObject_CallFinalizerFromDealloc]
26982696
added = '3.15'

Modules/_testlimitedcapi/object.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Need limited C API version 3.15 for PyObject_CallFinalizer()
1+
// Need limited C API version 3.13 for Py_GetConstant()
22
#include "pyconfig.h" // Py_GIL_DISABLED
33
#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
4-
# define Py_LIMITED_API 0x030f0000
4+
# define Py_LIMITED_API 0x030d0000
55
#endif
66

77
#include "parts.h"
@@ -62,25 +62,19 @@ test_constants(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
6262
Py_RETURN_NONE;
6363
}
6464

65-
66-
static PyObject *
67-
pyobject_callfinalizer(PyObject *Py_UNUSED(module), PyObject *obj)
68-
{
69-
PyObject_CallFinalizer(obj);
70-
Py_RETURN_NONE;
71-
}
72-
73-
7465
static PyMethodDef test_methods[] = {
7566
{"get_constant", get_constant, METH_VARARGS},
7667
{"get_constant_borrowed", get_constant_borrowed, METH_VARARGS},
7768
{"test_constants", test_constants, METH_NOARGS},
78-
{"pyobject_callfinalizer", pyobject_callfinalizer, METH_O},
7969
{NULL},
8070
};
8171

8272
int
8373
_PyTestLimitedCAPI_Init_Object(PyObject *m)
8474
{
85-
return PyModule_AddFunctions(m, test_methods);
75+
if (PyModule_AddFunctions(m, test_methods) < 0) {
76+
return -1;
77+
}
78+
79+
return 0;
8680
}

PC/python3dll.c

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)