@@ -140,6 +140,7 @@ static PyObject* frozendict_new(PyTypeObject *type, PyObject *args,
140140 PyObject * kwds );
141141static PyObject * dict_new (PyTypeObject * type , PyObject * args , PyObject * kwds );
142142static int dict_merge (PyObject * a , PyObject * b , int override );
143+ static int dict_contains (PyObject * op , PyObject * key );
143144static int dict_merge_from_seq2 (PyObject * d , PyObject * seq2 , int override );
144145
145146
@@ -4126,7 +4127,7 @@ dict_merge(PyObject *a, PyObject *b, int override)
41264127
41274128 for (key = PyIter_Next (iter ); key ; key = PyIter_Next (iter )) {
41284129 if (override != 1 ) {
4129- status = PyDict_Contains (a , key );
4130+ status = dict_contains (a , key );
41304131 if (status != 0 ) {
41314132 if (status > 0 ) {
41324133 if (override == 0 ) {
@@ -4484,7 +4485,7 @@ static PyObject *
44844485dict___contains___impl (PyDictObject * self , PyObject * key )
44854486/*[clinic end generated code: output=1b314e6da7687dae input=fe1cb42ad831e820]*/
44864487{
4487- int contains = PyDict_Contains ((PyObject * )self , key );
4488+ int contains = dict_contains ((PyObject * )self , key );
44884489 if (contains < 0 ) {
44894490 return NULL ;
44904491 }
@@ -4984,9 +4985,8 @@ static PyMethodDef mapp_methods[] = {
49844985 {NULL , NULL } /* sentinel */
49854986};
49864987
4987- /* Return 1 if `key` is in dict `op`, 0 if not, and -1 on error. */
4988- int
4989- PyDict_Contains (PyObject * op , PyObject * key )
4988+ static int
4989+ dict_contains (PyObject * op , PyObject * key )
49904990{
49914991 Py_hash_t hash = _PyObject_HashFast (key );
49924992 if (hash == -1 ) {
@@ -4997,6 +4997,18 @@ PyDict_Contains(PyObject *op, PyObject *key)
49974997 return _PyDict_Contains_KnownHash (op , key , hash );
49984998}
49994999
5000+ /* Return 1 if `key` is in dict `op`, 0 if not, and -1 on error. */
5001+ int
5002+ PyDict_Contains (PyObject * op , PyObject * key )
5003+ {
5004+ if (!PyAnyDict_Check (op )) {
5005+ PyErr_BadInternalCall ();
5006+ return -1 ;
5007+ }
5008+
5009+ return dict_contains (op , key );
5010+ }
5011+
50005012int
50015013PyDict_ContainsString (PyObject * op , const char * key )
50025014{
@@ -5013,7 +5025,7 @@ PyDict_ContainsString(PyObject *op, const char *key)
50135025int
50145026_PyDict_Contains_KnownHash (PyObject * op , PyObject * key , Py_hash_t hash )
50155027{
5016- PyDictObject * mp = ( PyDictObject * ) op ;
5028+ PyDictObject * mp = _PyAnyDict_CAST ( op ) ;
50175029 PyObject * value ;
50185030 Py_ssize_t ix ;
50195031
@@ -5042,7 +5054,7 @@ static PySequenceMethods dict_as_sequence = {
50425054 0 , /* sq_slice */
50435055 0 , /* sq_ass_item */
50445056 0 , /* sq_ass_slice */
5045- PyDict_Contains , /* sq_contains */
5057+ dict_contains , /* sq_contains */
50465058 0 , /* sq_inplace_concat */
50475059 0 , /* sq_inplace_repeat */
50485060};
@@ -6292,7 +6304,7 @@ dictkeys_contains(PyObject *self, PyObject *obj)
62926304 _PyDictViewObject * dv = (_PyDictViewObject * )self ;
62936305 if (dv -> dv_dict == NULL )
62946306 return 0 ;
6295- return PyDict_Contains ((PyObject * )dv -> dv_dict , obj );
6307+ return dict_contains ((PyObject * )dv -> dv_dict , obj );
62966308}
62976309
62986310static PySequenceMethods dictkeys_as_sequence = {
0 commit comments