Skip to content

Commit 439c98c

Browse files
committed
Replace PyDict_Check() with _PyAnyDict_Check()
1 parent 9d6ca58 commit 439c98c

File tree

9 files changed

+34
-34
lines changed

9 files changed

+34
-34
lines changed

Modules/_collectionsmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2403,7 +2403,7 @@ defdict_or(PyObject* left, PyObject* right)
24032403
self = right;
24042404
other = left;
24052405
}
2406-
if (!PyDict_Check(other)) {
2406+
if (!_PyAnyDict_Check(other)) {
24072407
Py_RETURN_NOTIMPLEMENTED;
24082408
}
24092409
// Like copy(), this calls the object's class.

Objects/abstract.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ PyObject_GetItem(PyObject *o, PyObject *key)
208208
int
209209
PyMapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **result)
210210
{
211-
if (PyDict_CheckExact(obj)) {
211+
if (_PyAnyDict_CheckExact(obj)) {
212212
return PyDict_GetItemRef(obj, key, result);
213213
}
214214

@@ -1672,7 +1672,7 @@ PyNumber_ToBase(PyObject *n, int base)
16721672
int
16731673
PySequence_Check(PyObject *s)
16741674
{
1675-
if (PyDict_Check(s))
1675+
if (_PyAnyDict_Check(s))
16761676
return 0;
16771677
return Py_TYPE(s)->tp_as_sequence &&
16781678
Py_TYPE(s)->tp_as_sequence->sq_item != NULL;
@@ -2454,7 +2454,7 @@ PyMapping_Keys(PyObject *o)
24542454
if (o == NULL) {
24552455
return null_error();
24562456
}
2457-
if (PyDict_CheckExact(o)) {
2457+
if (_PyAnyDict_CheckExact(o)) {
24582458
return PyDict_Keys(o);
24592459
}
24602460
return method_output_as_list(o, &_Py_ID(keys));
@@ -2466,7 +2466,7 @@ PyMapping_Items(PyObject *o)
24662466
if (o == NULL) {
24672467
return null_error();
24682468
}
2469-
if (PyDict_CheckExact(o)) {
2469+
if (_PyAnyDict_CheckExact(o)) {
24702470
return PyDict_Items(o);
24712471
}
24722472
return method_output_as_list(o, &_Py_ID(items));
@@ -2478,7 +2478,7 @@ PyMapping_Values(PyObject *o)
24782478
if (o == NULL) {
24792479
return null_error();
24802480
}
2481-
if (PyDict_CheckExact(o)) {
2481+
if (_PyAnyDict_CheckExact(o)) {
24822482
return PyDict_Values(o);
24832483
}
24842484
return method_output_as_list(o, &_Py_ID(values));

Objects/descrobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ static int
10891089
mappingproxy_contains(PyObject *self, PyObject *key)
10901090
{
10911091
mappingproxyobject *pp = (mappingproxyobject *)self;
1092-
if (PyDict_CheckExact(pp->mapping))
1092+
if (_PyAnyDict_CheckExact(pp->mapping))
10931093
return PyDict_Contains(pp->mapping, key);
10941094
else
10951095
return PySequence_Contains(pp->mapping, key);

Objects/dictobject.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ new_dict_with_shared_keys(PyDictKeysObject *keys)
914914
static PyDictKeysObject *
915915
clone_combined_dict_keys(PyDictObject *orig)
916916
{
917-
assert(PyDict_Check(orig));
917+
assert(_PyAnyDict_Check(orig));
918918
assert(Py_TYPE(orig)->tp_iter == dict_iter);
919919
assert(orig->ma_values == NULL);
920920
assert(orig->ma_keys != Py_EMPTY_KEYS);
@@ -2374,7 +2374,7 @@ _PyDict_GetItem_KnownHash(PyObject *op, PyObject *key, Py_hash_t hash)
23742374
PyDictObject *mp = (PyDictObject *)op;
23752375
PyObject *value;
23762376

2377-
if (!PyDict_Check(op)) {
2377+
if (!_PyAnyDict_Check(op)) {
23782378
PyErr_BadInternalCall();
23792379
return NULL;
23802380
}
@@ -3280,8 +3280,8 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
32803280
return NULL;
32813281

32823282

3283-
if (PyDict_CheckExact(d)) {
3284-
if (PyDict_CheckExact(iterable)) {
3283+
if (_PyAnyDict_CheckExact(d)) {
3284+
if (_PyAnyDict_CheckExact(iterable)) {
32853285
PyDictObject *mp = (PyDictObject *)d;
32863286

32873287
Py_BEGIN_CRITICAL_SECTION2(d, iterable);
@@ -3496,7 +3496,7 @@ dict_subscript(PyObject *self, PyObject *key)
34963496
if (ix == DKIX_ERROR)
34973497
return NULL;
34983498
if (ix == DKIX_EMPTY || value == NULL) {
3499-
if (!PyDict_CheckExact(mp)) {
3499+
if (!_PyAnyDict_CheckExact(mp)) {
35003500
/* Look up __missing__ method if we're a subclass. */
35013501
PyObject *missing, *res;
35023502
missing = _PyObject_LookupSpecial(
@@ -3535,7 +3535,7 @@ keys_lock_held(PyObject *dict)
35353535
{
35363536
ASSERT_DICT_LOCKED(dict);
35373537

3538-
if (dict == NULL || !PyDict_Check(dict)) {
3538+
if (dict == NULL || !_PyAnyDict_Check(dict)) {
35393539
PyErr_BadInternalCall();
35403540
return NULL;
35413541
}
@@ -3584,7 +3584,7 @@ values_lock_held(PyObject *dict)
35843584
{
35853585
ASSERT_DICT_LOCKED(dict);
35863586

3587-
if (dict == NULL || !PyDict_Check(dict)) {
3587+
if (dict == NULL || !_PyAnyDict_Check(dict)) {
35883588
PyErr_BadInternalCall();
35893589
return NULL;
35903590
}
@@ -3632,7 +3632,7 @@ items_lock_held(PyObject *dict)
36323632
{
36333633
ASSERT_DICT_LOCKED(dict);
36343634

3635-
if (dict == NULL || !PyDict_Check(dict)) {
3635+
if (dict == NULL || !_PyAnyDict_Check(dict)) {
36363636
PyErr_BadInternalCall();
36373637
return NULL;
36383638
}
@@ -3712,7 +3712,7 @@ dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value)
37123712
static int
37133713
dict_update_arg(PyObject *self, PyObject *arg)
37143714
{
3715-
if (PyDict_CheckExact(arg)) {
3715+
if (_PyAnyDict_CheckExact(arg)) {
37163716
return PyDict_Merge(self, arg, 1);
37173717
}
37183718
int has_keys = PyObject_HasAttrWithError(arg, &_Py_ID(keys));
@@ -3982,7 +3982,7 @@ dict_merge(PyInterpreterState *interp, PyObject *a, PyObject *b, int override)
39823982
}
39833983
mp = (PyDictObject*)a;
39843984
int res = 0;
3985-
if (PyDict_Check(b) && (Py_TYPE(b)->tp_iter == dict_iter)) {
3985+
if (_PyAnyDict_Check(b) && (Py_TYPE(b)->tp_iter == dict_iter)) {
39863986
other = (PyDictObject*)b;
39873987
int res;
39883988
Py_BEGIN_CRITICAL_SECTION2(a, b);
@@ -4243,7 +4243,7 @@ PyDict_Copy(PyObject *o)
42434243
Py_ssize_t
42444244
PyDict_Size(PyObject *mp)
42454245
{
4246-
if (mp == NULL || !PyDict_Check(mp)) {
4246+
if (mp == NULL || !_PyAnyDict_Check(mp)) {
42474247
PyErr_BadInternalCall();
42484248
return -1;
42494249
}
@@ -5789,7 +5789,7 @@ dictreviter_iter_lock_held(PyDictObject *d, PyObject *self)
57895789
{
57905790
dictiterobject *di = (dictiterobject *)self;
57915791

5792-
assert (PyDict_Check(d));
5792+
assert (_PyAnyDict_Check(d));
57935793
ASSERT_DICT_LOCKED(d);
57945794

57955795
if (di->di_used != d->ma_used) {
@@ -5919,7 +5919,7 @@ static PyObject *
59195919
dict___reversed___impl(PyDictObject *self)
59205920
/*[clinic end generated code: output=e674483336d1ed51 input=23210ef3477d8c4d]*/
59215921
{
5922-
assert (PyDict_Check(self));
5922+
assert (_PyAnyDict_Check(self));
59235923
return dictiter_new(self, &PyDictRevIterKey_Type);
59245924
}
59255925

@@ -6194,7 +6194,7 @@ dictviews_to_set(PyObject *self)
61946194
if (PyDictKeys_Check(self)) {
61956195
// PySet_New() has fast path for the dict object.
61966196
PyObject *dict = (PyObject *)((_PyDictViewObject *)self)->dv_dict;
6197-
if (PyDict_CheckExact(dict)) {
6197+
if (_PyAnyDict_CheckExact(dict)) {
61986198
left = dict;
61996199
}
62006200
}
@@ -7714,7 +7714,7 @@ validate_watcher_id(PyInterpreterState *interp, int watcher_id)
77147714
int
77157715
PyDict_Watch(int watcher_id, PyObject* dict)
77167716
{
7717-
if (!PyDict_Check(dict)) {
7717+
if (!_PyAnyDict_Check(dict)) {
77187718
PyErr_SetString(PyExc_ValueError, "Cannot watch non-dictionary");
77197719
return -1;
77207720
}
@@ -7729,7 +7729,7 @@ PyDict_Watch(int watcher_id, PyObject* dict)
77297729
int
77307730
PyDict_Unwatch(int watcher_id, PyObject* dict)
77317731
{
7732-
if (!PyDict_Check(dict)) {
7732+
if (!_PyAnyDict_Check(dict)) {
77337733
PyErr_SetString(PyExc_ValueError, "Cannot watch non-dictionary");
77347734
return -1;
77357735
}

Objects/listobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ _list_extend(PyListObject *self, PyObject *iterable)
14241424
res = list_extend_set(self, (PySetObject *)iterable);
14251425
Py_END_CRITICAL_SECTION2();
14261426
}
1427-
else if (PyDict_CheckExact(iterable)) {
1427+
else if (_PyAnyDict_CheckExact(iterable)) {
14281428
Py_BEGIN_CRITICAL_SECTION2(self, iterable);
14291429
res = list_extend_dict(self, (PyDictObject *)iterable, 0 /*keys*/);
14301430
Py_END_CRITICAL_SECTION2();

Objects/object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ _PyObject_CheckConsistency(PyObject *op, int check_content)
5757
if (PyUnicode_Check(op)) {
5858
_PyUnicode_CheckConsistency(op, check_content);
5959
}
60-
else if (PyDict_Check(op)) {
60+
else if (_PyAnyDict_Check(op)) {
6161
_PyDict_CheckConsistency(op, check_content);
6262
}
6363
return 1;

Objects/odictobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,7 @@ static int
22722272
mutablemapping_update_arg(PyObject *self, PyObject *arg)
22732273
{
22742274
int res = 0;
2275-
if (PyDict_CheckExact(arg)) {
2275+
if (_PyAnyDict_CheckExact(arg)) {
22762276
PyObject *items = PyDict_Items(arg);
22772277
if (items == NULL) {
22782278
return -1;

Objects/setobject.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ set_iter(PyObject *so)
989989
static int
990990
set_update_dict_lock_held(PySetObject *so, PyObject *other)
991991
{
992-
assert(PyDict_CheckExact(other));
992+
assert(_PyAnyDict_CheckExact(other));
993993

994994
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(so);
995995
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(other);
@@ -1048,7 +1048,7 @@ set_update_lock_held(PySetObject *so, PyObject *other)
10481048
if (PyAnySet_Check(other)) {
10491049
return set_merge_lock_held(so, other);
10501050
}
1051-
else if (PyDict_CheckExact(other)) {
1051+
else if (_PyAnyDict_CheckExact(other)) {
10521052
return set_update_dict_lock_held(so, other);
10531053
}
10541054
return set_update_iterable_lock_held(so, other);
@@ -1066,7 +1066,7 @@ set_update_local(PySetObject *so, PyObject *other)
10661066
Py_END_CRITICAL_SECTION();
10671067
return rv;
10681068
}
1069-
else if (PyDict_CheckExact(other)) {
1069+
else if (_PyAnyDict_CheckExact(other)) {
10701070
int rv;
10711071
Py_BEGIN_CRITICAL_SECTION(other);
10721072
rv = set_update_dict_lock_held(so, other);
@@ -1089,7 +1089,7 @@ set_update_internal(PySetObject *so, PyObject *other)
10891089
Py_END_CRITICAL_SECTION2();
10901090
return rv;
10911091
}
1092-
else if (PyDict_CheckExact(other)) {
1092+
else if (_PyAnyDict_CheckExact(other)) {
10931093
int rv;
10941094
Py_BEGIN_CRITICAL_SECTION2(so, other);
10951095
rv = set_update_dict_lock_held(so, other);
@@ -1781,7 +1781,7 @@ set_difference(PySetObject *so, PyObject *other)
17811781
if (PyAnySet_Check(other)) {
17821782
other_size = PySet_GET_SIZE(other);
17831783
}
1784-
else if (PyDict_CheckExact(other)) {
1784+
else if (_PyAnyDict_CheckExact(other)) {
17851785
other_size = PyDict_GET_SIZE(other);
17861786
}
17871787
else {
@@ -1798,7 +1798,7 @@ set_difference(PySetObject *so, PyObject *other)
17981798
if (result == NULL)
17991799
return NULL;
18001800

1801-
if (PyDict_CheckExact(other)) {
1801+
if (_PyAnyDict_CheckExact(other)) {
18021802
while (set_next(so, &pos, &entry)) {
18031803
key = entry->key;
18041804
hash = entry->hash;
@@ -1989,7 +1989,7 @@ set_symmetric_difference_update_impl(PySetObject *so, PyObject *other)
19891989
}
19901990

19911991
int rv;
1992-
if (PyDict_CheckExact(other)) {
1992+
if (_PyAnyDict_CheckExact(other)) {
19931993
Py_BEGIN_CRITICAL_SECTION2(so, other);
19941994
rv = set_symmetric_difference_update_dict(so, other);
19951995
Py_END_CRITICAL_SECTION2();

Objects/unicodeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13189,7 +13189,7 @@ unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z)
1318913189
const void *data;
1319013190

1319113191
/* x must be a dict */
13192-
if (!PyDict_CheckExact(x)) {
13192+
if (!_PyAnyDict_CheckExact(x)) {
1319313193
PyErr_SetString(PyExc_TypeError, "if you give only one argument "
1319413194
"to maketrans it must be a dict");
1319513195
goto err;

0 commit comments

Comments
 (0)