diff options
author | Victor Stinner <vstinner@python.org> | 2020-04-13 09:38:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 09:38:42 (GMT) |
commit | 0135598d729d01f35ce08d47160adaa095a6149f (patch) | |
tree | b272b49c6e2ed7b5270f9aeb565fe61a5ff9d634 /Modules | |
parent | 85dd6bb1f61f7edcd6ac0b640a98644531690a0e (diff) | |
download | cpython-0135598d729d01f35ce08d47160adaa095a6149f.zip cpython-0135598d729d01f35ce08d47160adaa095a6149f.tar.gz cpython-0135598d729d01f35ce08d47160adaa095a6149f.tar.bz2 |
bpo-40241: Add pycore_gc.h header file (GH-19494)
Move the PyGC_Head structure and the following private macros to the
internal C API:
* _PyGCHead_FINALIZED()
* _PyGCHead_NEXT()
* _PyGCHead_PREV()
* _PyGCHead_SET_FINALIZED()
* _PyGCHead_SET_NEXT()
* _PyGCHead_SET_PREV()
* _PyGC_FINALIZED()
* _PyGC_PREV_MASK
* _PyGC_PREV_MASK_COLLECTING
* _PyGC_PREV_MASK_FINALIZED
* _PyGC_PREV_SHIFT
* _PyGC_SET_FINALIZED()
* _PyObject_GC_IS_TRACKED()
* _PyObject_GC_MAY_BE_TRACKED()
* _Py_AS_GC(o)
Keep the private _PyGC_FINALIZED() macro in the public C API for
backward compatibility with Python 3.8: make it an alias to the new
PyObject_GC_IsFinalized() function.
Move the SIZEOF_PYGC_HEAD constant from _testcapi module to
_testinternalcapi module.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 1 | ||||
-rw-r--r-- | Modules/_testinternalcapi.c | 17 |
2 files changed, 16 insertions, 2 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 0a30fea..c97cbe8 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -6716,7 +6716,6 @@ PyInit__testcapi(void) PyModule_AddObject(m, "ULLONG_MAX", PyLong_FromUnsignedLongLong(ULLONG_MAX)); PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyLong_FromSsize_t(PY_SSIZE_T_MAX)); PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyLong_FromSsize_t(PY_SSIZE_T_MIN)); - PyModule_AddObject(m, "SIZEOF_PYGC_HEAD", PyLong_FromSsize_t(sizeof(PyGC_Head))); PyModule_AddObject(m, "SIZEOF_TIME_T", PyLong_FromSsize_t(sizeof(time_t))); Py_INCREF(&PyInstanceMethod_Type); PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type); diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c index 394b870..8352f6e 100644 --- a/Modules/_testinternalcapi.c +++ b/Modules/_testinternalcapi.c @@ -10,6 +10,7 @@ #include "Python.h" #include "pycore_initconfig.h" // _Py_GetConfigsAsDict() +#include "pycore_gc.h" // PyGC_Head static PyObject * @@ -52,5 +53,19 @@ static struct PyModuleDef _testcapimodule = { PyMODINIT_FUNC PyInit__testinternalcapi(void) { - return PyModule_Create(&_testcapimodule); + PyObject *module = PyModule_Create(&_testcapimodule); + if (module == NULL) { + return NULL; + } + + if (PyModule_AddObject(module, "SIZEOF_PYGC_HEAD", + PyLong_FromSsize_t(sizeof(PyGC_Head))) < 0) { + goto error; + } + + return module; + +error: + Py_DECREF(module); + return NULL; } |