aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index c41bdb86dbf..18de42cba69 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1485,6 +1485,17 @@ PyDict_GetItemWithError(PyObject *op, PyObject *key)
}
PyObject *
+_PyDict_GetItemWithError(PyObject *dp, PyObject *kv)
+{
+ assert(PyUnicode_CheckExact(kv));
+ Py_hash_t hash = kv->ob_type->tp_hash(kv);
+ if (hash == -1) {
+ return NULL;
+ }
+ return _PyDict_GetItem_KnownHash(dp, kv, hash);
+}
+
+PyObject *
_PyDict_GetItemIdWithError(PyObject *dp, struct _Py_Identifier *key)
{
PyObject *kv;
@@ -2166,8 +2177,8 @@ dict_subscript(PyDictObject *mp, PyObject *key)
if (!PyDict_CheckExact(mp)) {
/* Look up __missing__ method if we're a subclass. */
PyObject *missing, *res;
- _Py_IDENTIFIER(__missing__);
- missing = _PyObject_LookupSpecial((PyObject *)mp, &PyId___missing__);
+ missing = _PyObject_LookupSpecial(
+ (PyObject *)mp, &_Py_ID(__missing__));
if (missing != NULL) {
res = PyObject_CallOneArg(missing, key);
Py_DECREF(missing);
@@ -2369,9 +2380,8 @@ dict_update_arg(PyObject *self, PyObject *arg)
if (PyDict_CheckExact(arg)) {
return PyDict_Merge(self, arg, 1);
}
- _Py_IDENTIFIER(keys);
PyObject *func;
- if (_PyObject_LookupAttrId(arg, &PyId_keys, &func) < 0) {
+ if (_PyObject_LookupAttr(arg, &_Py_ID(keys), &func) < 0) {
return -1;
}
if (func != NULL) {
@@ -4128,7 +4138,6 @@ dict___reversed___impl(PyDictObject *self)
static PyObject *
dictiter_reduce(dictiterobject *di, PyObject *Py_UNUSED(ignored))
{
- _Py_IDENTIFIER(iter);
/* copy the iterator state */
dictiterobject tmp = *di;
Py_XINCREF(tmp.di_dict);
@@ -4138,7 +4147,7 @@ dictiter_reduce(dictiterobject *di, PyObject *Py_UNUSED(ignored))
if (list == NULL) {
return NULL;
}
- return Py_BuildValue("N(N)", _PyEval_GetBuiltinId(&PyId_iter), list);
+ return Py_BuildValue("N(N)", _PyEval_GetBuiltin(&_Py_ID(iter)), list);
}
PyTypeObject PyDictRevIterItem_Type = {
@@ -4408,9 +4417,8 @@ dictviews_sub(PyObject *self, PyObject *other)
return NULL;
}
- _Py_IDENTIFIER(difference_update);
- PyObject *tmp = _PyObject_CallMethodIdOneArg(
- result, &PyId_difference_update, other);
+ PyObject *tmp = PyObject_CallMethodOneArg(
+ result, &_Py_ID(difference_update), other);
if (tmp == NULL) {
Py_DECREF(result);
return NULL;
@@ -4446,8 +4454,8 @@ _PyDictView_Intersect(PyObject* self, PyObject *other)
/* if other is a set and self is smaller than other,
reuse set intersection logic */
if (PySet_CheckExact(other) && len_self <= PyObject_Size(other)) {
- _Py_IDENTIFIER(intersection);
- return _PyObject_CallMethodIdObjArgs(other, &PyId_intersection, self, NULL);
+ return PyObject_CallMethodObjArgs(
+ other, &_Py_ID(intersection), self, NULL);
}
/* if other is another dict view, and it is bigger than self,
@@ -4587,9 +4595,8 @@ dictitems_xor(PyObject *self, PyObject *other)
}
key = val1 = val2 = NULL;
- _Py_IDENTIFIER(items);
- PyObject *remaining_pairs = _PyObject_CallMethodIdNoArgs(temp_dict,
- &PyId_items);
+ PyObject *remaining_pairs = PyObject_CallMethodNoArgs(
+ temp_dict, &_Py_ID(items));
if (remaining_pairs == NULL) {
goto error;
}
@@ -4621,9 +4628,8 @@ dictviews_xor(PyObject* self, PyObject *other)
return NULL;
}
- _Py_IDENTIFIER(symmetric_difference_update);
- PyObject *tmp = _PyObject_CallMethodIdOneArg(
- result, &PyId_symmetric_difference_update, other);
+ PyObject *tmp = PyObject_CallMethodOneArg(
+ result, &_Py_ID(symmetric_difference_update), other);
if (tmp == NULL) {
Py_DECREF(result);
return NULL;