From af8e4e8c88d3f660282210613f72a0e7bae3aece Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 12 Mar 2022 18:19:39 +0900 Subject: [PATCH 1/3] bpo-46987: Remove _PySys_GetObjectId / _PySys_GetObjectId --- Include/cpython/sysmodule.h | 2 -- .../C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst | 1 + Python/sysmodule.c | 14 -------------- 3 files changed, 1 insertion(+), 16 deletions(-) create mode 100644 Misc/NEWS.d/next/C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst diff --git a/Include/cpython/sysmodule.h b/Include/cpython/sysmodule.h index 27dff7b2e3d930..19d9dddc344a4f 100644 --- a/Include/cpython/sysmodule.h +++ b/Include/cpython/sysmodule.h @@ -4,8 +4,6 @@ PyAPI_FUNC(PyObject *) _PySys_GetAttr(PyThreadState *tstate, PyObject *name); -PyAPI_FUNC(PyObject *) _PySys_GetObjectId(_Py_Identifier *key); -PyAPI_FUNC(int) _PySys_SetObjectId(_Py_Identifier *key, PyObject *); PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *); diff --git a/Misc/NEWS.d/next/C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst b/Misc/NEWS.d/next/C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst new file mode 100644 index 00000000000000..a2d8a94e27b095 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst @@ -0,0 +1 @@ +Remove _PySys_GetObjectId and _PySys_GetObjectId. Patch by Dong-hee Na. diff --git a/Python/sysmodule.c b/Python/sysmodule.c index a97d0341ddcfd7..00aa410df378e6 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -88,13 +88,6 @@ sys_get_object_id(PyThreadState *tstate, _Py_Identifier *key) return value; } -PyObject * -_PySys_GetObjectId(_Py_Identifier *key) -{ - PyThreadState *tstate = _PyThreadState_GET(); - return sys_get_object_id(tstate, key); -} - static PyObject * _PySys_GetObject(PyInterpreterState *interp, const char *name) { @@ -145,13 +138,6 @@ sys_set_object_id(PyInterpreterState *interp, _Py_Identifier *key, PyObject *v) return sys_set_object(interp, _PyUnicode_FromId(key), v); } -int -_PySys_SetObjectId(_Py_Identifier *key, PyObject *v) -{ - PyInterpreterState *interp = _PyInterpreterState_GET(); - return sys_set_object_id(interp, key, v); -} - int _PySys_SetAttr(PyObject *key, PyObject *v) { From 38c95ec14b66ec50a32407895c15c70066c94022 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 12 Mar 2022 21:18:53 +0900 Subject: [PATCH 2/3] bpo-46987: Remove sys_get_object_id / sys_set_object_id --- Python/sysmodule.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 00aa410df378e6..99540b09c1f465 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -72,22 +72,6 @@ _PySys_GetAttr(PyThreadState *tstate, PyObject *name) return value; } -static PyObject * -sys_get_object_id(PyThreadState *tstate, _Py_Identifier *key) -{ - PyObject *sd = tstate->interp->sysdict; - if (sd == NULL) { - return NULL; - } - PyObject *exc_type, *exc_value, *exc_tb; - _PyErr_Fetch(tstate, &exc_type, &exc_value, &exc_tb); - PyObject *value = _PyDict_GetItemIdWithError(sd, key); - /* XXX Suppress a new exception if it was raised and restore - * the old one. */ - _PyErr_Restore(tstate, exc_type, exc_value, exc_tb); - return value; -} - static PyObject * _PySys_GetObject(PyInterpreterState *interp, const char *name) { @@ -132,12 +116,6 @@ sys_set_object(PyInterpreterState *interp, PyObject *key, PyObject *v) } } -static int -sys_set_object_id(PyInterpreterState *interp, _Py_Identifier *key, PyObject *v) -{ - return sys_set_object(interp, _PyUnicode_FromId(key), v); -} - int _PySys_SetAttr(PyObject *key, PyObject *v) { From 2bdd112d71985bf92029c442c6e5924c1ac68324 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Mon, 14 Mar 2022 21:23:25 +0900 Subject: [PATCH 3/3] bpo-46987: Address code review --- .../NEWS.d/next/C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst b/Misc/NEWS.d/next/C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst index a2d8a94e27b095..2c858afdf1f479 100644 --- a/Misc/NEWS.d/next/C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst +++ b/Misc/NEWS.d/next/C API/2022-03-12-18-37-06.bpo-46987.LWcwyN.rst @@ -1 +1,2 @@ -Remove _PySys_GetObjectId and _PySys_GetObjectId. Patch by Dong-hee Na. +Remove private functions ``_PySys_GetObjectId()`` and ``_PySys_SetObjectId()``. +Patch by Dong-hee Na.