Skip to content

Commit 7e5fcae

Browse files
authored
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.
1 parent 4172644 commit 7e5fcae

File tree

9 files changed

+0
-172
lines changed

9 files changed

+0
-172
lines changed

Include/internal/pycore_call.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -64,39 +64,6 @@ PyAPI_FUNC(PyObject*) _PyObject_CallMethod(
6464
PyObject *name,
6565
const char *format, ...);
6666

67-
extern PyObject* _PyObject_CallMethodIdObjArgs(
68-
PyObject *obj,
69-
_Py_Identifier *name,
70-
...);
71-
72-
static inline PyObject *
73-
_PyObject_VectorcallMethodId(
74-
_Py_Identifier *name, PyObject *const *args,
75-
size_t nargsf, PyObject *kwnames)
76-
{
77-
PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
78-
if (!oname) {
79-
return _Py_NULL;
80-
}
81-
return PyObject_VectorcallMethod(oname, args, nargsf, kwnames);
82-
}
83-
84-
static inline PyObject *
85-
_PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
86-
{
87-
size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET;
88-
return _PyObject_VectorcallMethodId(name, &self, nargsf, _Py_NULL);
89-
}
90-
91-
static inline PyObject *
92-
_PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg)
93-
{
94-
PyObject *args[2] = {self, arg};
95-
size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET;
96-
assert(arg != NULL);
97-
return _PyObject_VectorcallMethodId(name, args, nargsf, _Py_NULL);
98-
}
99-
10067

10168
/* === Vectorcall protocol (PEP 590) ============================= */
10269

Include/internal/pycore_ceval.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ extern int _PyEval_SetOpcodeTrace(PyFrameObject *f, bool enable);
3333
// Export for 'array' shared extension
3434
PyAPI_FUNC(PyObject*) _PyEval_GetBuiltin(PyObject *);
3535

36-
extern PyObject* _PyEval_GetBuiltinId(_Py_Identifier *);
37-
3836
extern void _PyEval_SetSwitchInterval(unsigned long microseconds);
3937
extern unsigned long _PyEval_GetSwitchInterval(void);
4038

Include/internal/pycore_dict.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ extern int _PyDict_DelItem_KnownHash_LockHeld(PyObject *mp, PyObject *key,
3636

3737
extern int _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
3838

39-
// "Id" variants
40-
extern PyObject* _PyDict_GetItemIdWithError(PyObject *dp,
41-
_Py_Identifier *key);
42-
extern int _PyDict_ContainsId(PyObject *, _Py_Identifier *);
43-
extern int _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject *item);
44-
extern int _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key);
45-
4639
extern int _PyDict_Next(
4740
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
4841

Include/internal/pycore_unicodeobject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,6 @@ PyAPI_FUNC(PyObject*) _PyUnicode_JoinArray(
307307
Py_ssize_t seqlen
308308
);
309309

310-
/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
311-
0 otherwise. The right argument must be ASCII identifier.
312-
Any error occurs inside will be cleared before return. */
313-
extern int _PyUnicode_EqualToASCIIId(
314-
PyObject *left, /* Left string */
315-
_Py_Identifier *right /* Right identifier */
316-
);
317-
318310
// Test whether a unicode is equal to ASCII string. Return 1 if true,
319311
// 0 otherwise. The right argument must be ASCII-encoded string.
320312
// Any error occurs inside will be cleared before return.

Objects/call.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -891,39 +891,6 @@ PyObject_CallMethodObjArgs(PyObject *obj, PyObject *name, ...)
891891
}
892892

893893

894-
PyObject *
895-
_PyObject_CallMethodIdObjArgs(PyObject *obj, _Py_Identifier *name, ...)
896-
{
897-
PyThreadState *tstate = _PyThreadState_GET();
898-
if (obj == NULL || name == NULL) {
899-
return null_error(tstate);
900-
}
901-
902-
PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
903-
if (!oname) {
904-
return NULL;
905-
}
906-
_PyCStackRef method;
907-
_PyThreadState_PushCStackRef(tstate, &method);
908-
int is_method = _PyObject_GetMethodStackRef(tstate, obj, oname, &method.ref);
909-
if (PyStackRef_IsNull(method.ref)) {
910-
_PyThreadState_PopCStackRef(tstate, &method);
911-
return NULL;
912-
}
913-
PyObject *callable = PyStackRef_AsPyObjectBorrow(method.ref);
914-
915-
obj = is_method ? obj : NULL;
916-
917-
va_list vargs;
918-
va_start(vargs, name);
919-
PyObject *result = object_vacall(tstate, obj, callable, vargs);
920-
va_end(vargs);
921-
922-
_PyThreadState_PopCStackRef(tstate, &method);
923-
return result;
924-
}
925-
926-
927894
PyObject *
928895
PyObject_CallFunctionObjArgs(PyObject *callable, ...)
929896
{

Objects/dictobject.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,18 +2527,6 @@ _PyDict_GetItemWithError(PyObject *dp, PyObject *kv)
25272527
return _PyDict_GetItem_KnownHash(dp, kv, hash); // borrowed reference
25282528
}
25292529

2530-
PyObject *
2531-
_PyDict_GetItemIdWithError(PyObject *dp, _Py_Identifier *key)
2532-
{
2533-
PyObject *kv;
2534-
kv = _PyUnicode_FromId(key); /* borrowed */
2535-
if (kv == NULL)
2536-
return NULL;
2537-
Py_hash_t hash = unicode_get_hash(kv);
2538-
assert (hash != -1); /* interned strings have their hash value initialised */
2539-
return _PyDict_GetItem_KnownHash(dp, kv, hash); // borrowed reference
2540-
}
2541-
25422530
PyObject *
25432531
_PyDict_GetItemStringWithError(PyObject *v, const char *key)
25442532
{
@@ -4845,16 +4833,6 @@ _PyDict_Contains_KnownHash(PyObject *op, PyObject *key, Py_hash_t hash)
48454833
return 0;
48464834
}
48474835

4848-
int
4849-
_PyDict_ContainsId(PyObject *op, _Py_Identifier *key)
4850-
{
4851-
PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
4852-
if (kv == NULL) {
4853-
return -1;
4854-
}
4855-
return PyDict_Contains(op, kv);
4856-
}
4857-
48584836
/* Hack to implement "key in dict" */
48594837
static PySequenceMethods dict_as_sequence = {
48604838
0, /* sq_length */
@@ -5035,16 +5013,6 @@ PyDict_GetItemStringRef(PyObject *v, const char *key, PyObject **result)
50355013
return res;
50365014
}
50375015

5038-
int
5039-
_PyDict_SetItemId(PyObject *v, _Py_Identifier *key, PyObject *item)
5040-
{
5041-
PyObject *kv;
5042-
kv = _PyUnicode_FromId(key); /* borrowed */
5043-
if (kv == NULL)
5044-
return -1;
5045-
return PyDict_SetItem(v, kv, item);
5046-
}
5047-
50485016
int
50495017
PyDict_SetItemString(PyObject *v, const char *key, PyObject *item)
50505018
{
@@ -5060,15 +5028,6 @@ PyDict_SetItemString(PyObject *v, const char *key, PyObject *item)
50605028
return err;
50615029
}
50625030

5063-
int
5064-
_PyDict_DelItemId(PyObject *v, _Py_Identifier *key)
5065-
{
5066-
PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
5067-
if (kv == NULL)
5068-
return -1;
5069-
return PyDict_DelItem(v, kv);
5070-
}
5071-
50725031
int
50735032
PyDict_DelItemString(PyObject *v, const char *key)
50745033
{

Objects/odictobject.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ PyDict_DelItem PyMapping_DelItem
223223
PyDict_DelItemString PyMapping_DelItemString
224224
PyDict_GetItem -
225225
PyDict_GetItemWithError PyObject_GetItem
226-
_PyDict_GetItemIdWithError -
227226
PyDict_GetItemString PyMapping_GetItemString
228227
PyDict_Items PyMapping_Items
229228
PyDict_Keys PyMapping_Keys

Objects/unicodeobject.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11194,47 +11194,6 @@ _PyUnicode_EqualToASCIIString(PyObject *unicode, const char *str)
1119411194
memcmp(PyUnicode_1BYTE_DATA(unicode), str, len) == 0;
1119511195
}
1119611196

11197-
int
11198-
_PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
11199-
{
11200-
PyObject *right_uni;
11201-
11202-
assert(_PyUnicode_CHECK(left));
11203-
assert(right->string);
11204-
#ifndef NDEBUG
11205-
for (const char *p = right->string; *p; p++) {
11206-
assert((unsigned char)*p < 128);
11207-
}
11208-
#endif
11209-
11210-
if (!PyUnicode_IS_ASCII(left))
11211-
return 0;
11212-
11213-
right_uni = _PyUnicode_FromId(right); /* borrowed */
11214-
if (right_uni == NULL) {
11215-
/* memory error or bad data */
11216-
PyErr_Clear();
11217-
return _PyUnicode_EqualToASCIIString(left, right->string);
11218-
}
11219-
11220-
if (left == right_uni)
11221-
return 1;
11222-
11223-
assert(PyUnicode_CHECK_INTERNED(right_uni));
11224-
if (PyUnicode_CHECK_INTERNED(left)) {
11225-
return 0;
11226-
}
11227-
11228-
Py_hash_t right_hash = PyUnicode_HASH(right_uni);
11229-
assert(right_hash != -1);
11230-
Py_hash_t hash = PyUnicode_HASH(left);
11231-
if (hash != -1 && hash != right_hash) {
11232-
return 0;
11233-
}
11234-
11235-
return unicode_eq(left, right_uni);
11236-
}
11237-
1123811197
PyObject *
1123911198
PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
1124011199
{

Python/ceval.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,12 +2828,6 @@ _PyEval_GetBuiltin(PyObject *name)
28282828
return attr;
28292829
}
28302830

2831-
PyObject *
2832-
_PyEval_GetBuiltinId(_Py_Identifier *name)
2833-
{
2834-
return _PyEval_GetBuiltin(_PyUnicode_FromId(name));
2835-
}
2836-
28372831
PyObject *
28382832
PyEval_GetLocals(void)
28392833
{

0 commit comments

Comments
 (0)