From 6123c18e81841b256fbfece30c26ff6e8b1e4436 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Tue, 18 Jun 2024 13:46:46 +0100 Subject: [PATCH 1/3] gh-120686: remove unused internal c api functions --- Include/internal/pycore_identifier.h | 20 -------------------- Objects/object.c | 11 ----------- Objects/typeobject.c | 19 ------------------- 3 files changed, 50 deletions(-) delete mode 100644 Include/internal/pycore_identifier.h diff --git a/Include/internal/pycore_identifier.h b/Include/internal/pycore_identifier.h deleted file mode 100644 index cda28810a48196..00000000000000 --- a/Include/internal/pycore_identifier.h +++ /dev/null @@ -1,20 +0,0 @@ -/* String Literals: _Py_Identifier API */ - -#ifndef Py_INTERNAL_IDENTIFIER_H -#define Py_INTERNAL_IDENTIFIER_H -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef Py_BUILD_CORE -# error "this header requires Py_BUILD_CORE define" -#endif - -extern PyObject* _PyType_LookupId(PyTypeObject *, _Py_Identifier *); -extern PyObject* _PyObject_LookupSpecialId(PyObject *, _Py_Identifier *); -extern int _PyObject_SetAttrId(PyObject *, _Py_Identifier *, PyObject *); - -#ifdef __cplusplus -} -#endif -#endif // !Py_INTERNAL_IDENTIFIER_H diff --git a/Objects/object.c b/Objects/object.c index b7730475ac3768..36abf8fcd1c857 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1124,17 +1124,6 @@ _PyObject_GetAttrId(PyObject *v, _Py_Identifier *name) return result; } -int -_PyObject_SetAttrId(PyObject *v, _Py_Identifier *name, PyObject *w) -{ - int result; - PyObject *oname = _PyUnicode_FromId(name); /* borrowed */ - if (!oname) - return -1; - result = PyObject_SetAttr(v, oname, w); - return result; -} - int _PyObject_SetAttributeErrorContext(PyObject* v, PyObject* name) { diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 958f42430c80a2..18c570f4b7e094 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2705,15 +2705,6 @@ _PyObject_LookupSpecial(PyObject *self, PyObject *attr) return res; } -PyObject * -_PyObject_LookupSpecialId(PyObject *self, _Py_Identifier *attrid) -{ - PyObject *attr = _PyUnicode_FromId(attrid); /* borrowed */ - if (attr == NULL) - return NULL; - return _PyObject_LookupSpecial(self, attr); -} - static PyObject * lookup_maybe_method(PyObject *self, PyObject *attr, int *unbound) { @@ -5497,16 +5488,6 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name) return res; } -PyObject * -_PyType_LookupId(PyTypeObject *type, _Py_Identifier *name) -{ - PyObject *oname; - oname = _PyUnicode_FromId(name); /* borrowed */ - if (oname == NULL) - return NULL; - return _PyType_Lookup(type, oname); -} - static void set_flags(PyTypeObject *self, unsigned long mask, unsigned long flags) { From edbc7b8466b1ca4e0b0a22d21832cd2614cdacc3 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Tue, 18 Jun 2024 14:51:41 +0100 Subject: [PATCH 2/3] remove includes --- Include/internal/pycore_call.h | 1 - Include/internal/pycore_dict.h | 1 - Include/internal/pycore_unicodeobject.h | 1 - 3 files changed, 3 deletions(-) diff --git a/Include/internal/pycore_call.h b/Include/internal/pycore_call.h index c92028a01299e2..49f5c3322de267 100644 --- a/Include/internal/pycore_call.h +++ b/Include/internal/pycore_call.h @@ -8,7 +8,6 @@ extern "C" { # error "this header requires Py_BUILD_CORE define" #endif -#include "pycore_identifier.h" // _Py_Identifier #include "pycore_pystate.h" // _PyThreadState_GET() /* Suggested size (number of positional arguments) for arrays of PyObject* diff --git a/Include/internal/pycore_dict.h b/Include/internal/pycore_dict.h index cfe837b1e2b3ab..9e0e1237915e82 100644 --- a/Include/internal/pycore_dict.h +++ b/Include/internal/pycore_dict.h @@ -9,7 +9,6 @@ extern "C" { #endif #include "pycore_freelist.h" // _PyFreeListState -#include "pycore_identifier.h" // _Py_Identifier #include "pycore_object.h" // PyManagedDictPointer #include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_SSIZE_ACQUIRE diff --git a/Include/internal/pycore_unicodeobject.h b/Include/internal/pycore_unicodeobject.h index 026d6e461f2108..ccad36ff20a50d 100644 --- a/Include/internal/pycore_unicodeobject.h +++ b/Include/internal/pycore_unicodeobject.h @@ -10,7 +10,6 @@ extern "C" { #include "pycore_lock.h" // PyMutex #include "pycore_fileutils.h" // _Py_error_handler -#include "pycore_identifier.h" // _Py_Identifier #include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI /* --- Characters Type APIs ----------------------------------------------- */ From 247c115fff25c13ebf048b682dd96eaaae3d72bc Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Tue, 18 Jun 2024 16:21:55 +0100 Subject: [PATCH 3/3] update makefile --- Makefile.pre.in | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 22dba279faa935..d88ddc13e9a193 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1175,7 +1175,6 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_global_strings.h \ $(srcdir)/Include/internal/pycore_hamt.h \ $(srcdir)/Include/internal/pycore_hashtable.h \ - $(srcdir)/Include/internal/pycore_identifier.h \ $(srcdir)/Include/internal/pycore_import.h \ $(srcdir)/Include/internal/pycore_importdl.h \ $(srcdir)/Include/internal/pycore_initconfig.h \