https://github.com/python/cpython/commit/7e5fcae09bb0e87ed48cb593f7f46d715e48a102
commit: 7e5fcae09bb0e87ed48cb593f7f46d715e48a102
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-12-03T14:33:32+01:00
summary:
gh-142217: Remove internal _Py_Identifier functions (#142219)
Remove internal functions:
* _PyDict_ContainsId()
* _PyDict_DelItemId()
* _PyDict_GetItemIdWithError()
* _PyDict_SetItemId()
* _PyEval_GetBuiltinId()
* _PyObject_CallMethodIdNoArgs()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_CallMethodIdOneArg()
* _PyObject_VectorcallMethodId()
* _PyUnicode_EqualToASCIIId()
These functions were not exported and so no usable outside CPython.
files:
M Include/internal/pycore_call.h
M Include/internal/pycore_ceval.h
M Include/internal/pycore_dict.h
M Include/internal/pycore_unicodeobject.h
M Objects/call.c
M Objects/dictobject.c
M Objects/odictobject.c
M Objects/unicodeobject.c
M Python/ceval.c
diff --git a/Include/internal/pycore_call.h b/Include/internal/pycore_call.h
index 506da06f7087d2..4f4cf02f64b828 100644
--- a/Include/internal/pycore_call.h
+++ b/Include/internal/pycore_call.h
@@ -64,39 +64,6 @@ PyAPI_FUNC(PyObject*) _PyObject_CallMethod(
PyObject *name,
const char *format, ...);
-extern PyObject* _PyObject_CallMethodIdObjArgs(
- PyObject *obj,
- _Py_Identifier *name,
- ...);
-
-static inline PyObject *
-_PyObject_VectorcallMethodId(
- _Py_Identifier *name, PyObject *const *args,
- size_t nargsf, PyObject *kwnames)
-{
- PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
- if (!oname) {
- return _Py_NULL;
- }
- return PyObject_VectorcallMethod(oname, args, nargsf, kwnames);
-}
-
-static inline PyObject *
-_PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
-{
- size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET;
- return _PyObject_VectorcallMethodId(name, &self, nargsf, _Py_NULL);
-}
-
-static inline PyObject *
-_PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject
*arg)
-{
- PyObject *args[2] = {self, arg};
- size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET;
- assert(arg != NULL);
- return _PyObject_VectorcallMethodId(name, args, nargsf, _Py_NULL);
-}
-
/* === Vectorcall protocol (PEP 590) ============================= */
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index 9d81833a2343f2..762d8ef067e288 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -33,8 +33,6 @@ extern int _PyEval_SetOpcodeTrace(PyFrameObject *f, bool
enable);
// Export for 'array' shared extension
PyAPI_FUNC(PyObject*) _PyEval_GetBuiltin(PyObject *);
-extern PyObject* _PyEval_GetBuiltinId(_Py_Identifier *);
-
extern void _PyEval_SetSwitchInterval(unsigned long microseconds);
extern unsigned long _PyEval_GetSwitchInterval(void);
diff --git a/Include/internal/pycore_dict.h b/Include/internal/pycore_dict.h
index b8fe360321d14b..1193f496da132d 100644
--- a/Include/internal/pycore_dict.h
+++ b/Include/internal/pycore_dict.h
@@ -36,13 +36,6 @@ extern int _PyDict_DelItem_KnownHash_LockHeld(PyObject *mp,
PyObject *key,
extern int _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
-// "Id" variants
-extern PyObject* _PyDict_GetItemIdWithError(PyObject *dp,
- _Py_Identifier *key);
-extern int _PyDict_ContainsId(PyObject *, _Py_Identifier *);
-extern int _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject
*item);
-extern int _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key);
-
extern int _PyDict_Next(
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t
*hash);
diff --git a/Include/internal/pycore_unicodeobject.h
b/Include/internal/pycore_unicodeobject.h
index e7ca65a56b6ec3..97dda73f9b584d 100644
--- a/Include/internal/pycore_unicodeobject.h
+++ b/Include/internal/pycore_unicodeobject.h
@@ -307,14 +307,6 @@ PyAPI_FUNC(PyObject*) _PyUnicode_JoinArray(
Py_ssize_t seqlen
);
-/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
- 0 otherwise. The right argument must be ASCII identifier.
- Any error occurs inside will be cleared before return. */
-extern int _PyUnicode_EqualToASCIIId(
- PyObject *left, /* Left string */
- _Py_Identifier *right /* Right identifier */
- );
-
// Test whether a unicode is equal to ASCII string. Return 1 if true,
// 0 otherwise. The right argument must be ASCII-encoded string.
// Any error occurs inside will be cleared before return.
diff --git a/Objects/call.c b/Objects/call.c
index bd8617825b585e..c69015abfb3ed5 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -891,39 +891,6 @@ PyObject_CallMethodObjArgs(PyObject *obj, PyObject *name,
...)
}
-PyObject *
-_PyObject_CallMethodIdObjArgs(PyObject *obj, _Py_Identifier *name, ...)
-{
- PyThreadState *tstate = _PyThreadState_GET();
- if (obj == NULL || name == NULL) {
- return null_error(tstate);
- }
-
- PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
- if (!oname) {
- return NULL;
- }
- _PyCStackRef method;
- _PyThreadState_PushCStackRef(tstate, &method);
- int is_method = _PyObject_GetMethodStackRef(tstate, obj, oname,
&method.ref);
- if (PyStackRef_IsNull(method.ref)) {
- _PyThreadState_PopCStackRef(tstate, &method);
- return NULL;
- }
- PyObject *callable = PyStackRef_AsPyObjectBorrow(method.ref);
-
- obj = is_method ? obj : NULL;
-
- va_list vargs;
- va_start(vargs, name);
- PyObject *result = object_vacall(tstate, obj, callable, vargs);
- va_end(vargs);
-
- _PyThreadState_PopCStackRef(tstate, &method);
- return result;
-}
-
-
PyObject *
PyObject_CallFunctionObjArgs(PyObject *callable, ...)
{
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 14de21f3c67210..ee1c173ae4abb0 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2527,18 +2527,6 @@ _PyDict_GetItemWithError(PyObject *dp, PyObject *kv)
return _PyDict_GetItem_KnownHash(dp, kv, hash); // borrowed reference
}
-PyObject *
-_PyDict_GetItemIdWithError(PyObject *dp, _Py_Identifier *key)
-{
- PyObject *kv;
- kv = _PyUnicode_FromId(key); /* borrowed */
- if (kv == NULL)
- return NULL;
- Py_hash_t hash = unicode_get_hash(kv);
- assert (hash != -1); /* interned strings have their hash value
initialised */
- return _PyDict_GetItem_KnownHash(dp, kv, hash); // borrowed reference
-}
-
PyObject *
_PyDict_GetItemStringWithError(PyObject *v, const char *key)
{
@@ -4845,16 +4833,6 @@ _PyDict_Contains_KnownHash(PyObject *op, PyObject *key,
Py_hash_t hash)
return 0;
}
-int
-_PyDict_ContainsId(PyObject *op, _Py_Identifier *key)
-{
- PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
- if (kv == NULL) {
- return -1;
- }
- return PyDict_Contains(op, kv);
-}
-
/* Hack to implement "key in dict" */
static PySequenceMethods dict_as_sequence = {
0, /* sq_length */
@@ -5035,16 +5013,6 @@ PyDict_GetItemStringRef(PyObject *v, const char *key,
PyObject **result)
return res;
}
-int
-_PyDict_SetItemId(PyObject *v, _Py_Identifier *key, PyObject *item)
-{
- PyObject *kv;
- kv = _PyUnicode_FromId(key); /* borrowed */
- if (kv == NULL)
- return -1;
- return PyDict_SetItem(v, kv, item);
-}
-
int
PyDict_SetItemString(PyObject *v, const char *key, PyObject *item)
{
@@ -5060,15 +5028,6 @@ PyDict_SetItemString(PyObject *v, const char *key,
PyObject *item)
return err;
}
-int
-_PyDict_DelItemId(PyObject *v, _Py_Identifier *key)
-{
- PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
- if (kv == NULL)
- return -1;
- return PyDict_DelItem(v, kv);
-}
-
int
PyDict_DelItemString(PyObject *v, const char *key)
{
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index 45d2ea0203a9ff..25928028919c9c 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -223,7 +223,6 @@ PyDict_DelItem PyMapping_DelItem
PyDict_DelItemString PyMapping_DelItemString
PyDict_GetItem -
PyDict_GetItemWithError PyObject_GetItem
-_PyDict_GetItemIdWithError -
PyDict_GetItemString PyMapping_GetItemString
PyDict_Items PyMapping_Items
PyDict_Keys PyMapping_Keys
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 7f9f75126a9e56..f737a885f197a0 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -11194,47 +11194,6 @@ _PyUnicode_EqualToASCIIString(PyObject *unicode, const
char *str)
memcmp(PyUnicode_1BYTE_DATA(unicode), str, len) == 0;
}
-int
-_PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
-{
- PyObject *right_uni;
-
- assert(_PyUnicode_CHECK(left));
- assert(right->string);
-#ifndef NDEBUG
- for (const char *p = right->string; *p; p++) {
- assert((unsigned char)*p < 128);
- }
-#endif
-
- if (!PyUnicode_IS_ASCII(left))
- return 0;
-
- right_uni = _PyUnicode_FromId(right); /* borrowed */
- if (right_uni == NULL) {
- /* memory error or bad data */
- PyErr_Clear();
- return _PyUnicode_EqualToASCIIString(left, right->string);
- }
-
- if (left == right_uni)
- return 1;
-
- assert(PyUnicode_CHECK_INTERNED(right_uni));
- if (PyUnicode_CHECK_INTERNED(left)) {
- return 0;
- }
-
- Py_hash_t right_hash = PyUnicode_HASH(right_uni);
- assert(right_hash != -1);
- Py_hash_t hash = PyUnicode_HASH(left);
- if (hash != -1 && hash != right_hash) {
- return 0;
- }
-
- return unicode_eq(left, right_uni);
-}
-
PyObject *
PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
{
diff --git a/Python/ceval.c b/Python/ceval.c
index 5381cd826dfd19..39fb38b7307814 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2828,12 +2828,6 @@ _PyEval_GetBuiltin(PyObject *name)
return attr;
}
-PyObject *
-_PyEval_GetBuiltinId(_Py_Identifier *name)
-{
- return _PyEval_GetBuiltin(_PyUnicode_FromId(name));
-}
-
PyObject *
PyEval_GetLocals(void)
{
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]