mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
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.
This commit is contained in:
parent
4172644d78
commit
7e5fcae09b
9 changed files with 0 additions and 172 deletions
|
|
@ -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) ============================= */
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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, ...)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue