Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(199308)

Side by Side Diff: Objects/dictobject.c

Issue 28189: dictitems_contains swallows compare errors
Patch Set: Created 2 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_dictviews.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Dictionary object implementation using a hash table */ 1 /* Dictionary object implementation using a hash table */
2 2
3 /* The distribution includes a separate file, Objects/dictnotes.txt, 3 /* The distribution includes a separate file, Objects/dictnotes.txt,
4 describing explorations into dictionary design and optimization. 4 describing explorations into dictionary design and optimization.
5 It covers typical dictionary use patterns, the parameters for 5 It covers typical dictionary use patterns, the parameters for
6 tuning dictionaries, and several ideas for possible optimizations. 6 tuning dictionaries, and several ideas for possible optimizations.
7 */ 7 */
8 8
9 /* PyDictKeysObject 9 /* PyDictKeysObject
10 10
(...skipping 4017 matching lines...) Expand 10 before | Expand all | Expand 10 after
4028 static int 4028 static int
4029 dictitems_contains(_PyDictViewObject *dv, PyObject *obj) 4029 dictitems_contains(_PyDictViewObject *dv, PyObject *obj)
4030 { 4030 {
4031 PyObject *key, *value, *found; 4031 PyObject *key, *value, *found;
4032 if (dv->dv_dict == NULL) 4032 if (dv->dv_dict == NULL)
4033 return 0; 4033 return 0;
4034 if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 2) 4034 if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 2)
4035 return 0; 4035 return 0;
4036 key = PyTuple_GET_ITEM(obj, 0); 4036 key = PyTuple_GET_ITEM(obj, 0);
4037 value = PyTuple_GET_ITEM(obj, 1); 4037 value = PyTuple_GET_ITEM(obj, 1);
4038 found = PyDict_GetItem((PyObject *)dv->dv_dict, key); 4038 found = PyDict_GetItemWithError((PyObject *)dv->dv_dict, key);
4039 if (found == NULL) { 4039 if (found == NULL) {
4040 if (PyErr_Occurred()) 4040 if (PyErr_Occurred())
4041 return -1; 4041 return -1;
4042 return 0; 4042 return 0;
4043 } 4043 }
4044 return PyObject_RichCompareBool(value, found, Py_EQ); 4044 return PyObject_RichCompareBool(value, found, Py_EQ);
4045 } 4045 }
4046 4046
4047 static PySequenceMethods dictitems_as_sequence = { 4047 static PySequenceMethods dictitems_as_sequence = {
4048 (lenfunc)dictview_len, /* sq_length */ 4048 (lenfunc)dictview_len, /* sq_length */
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
4259 } 4259 }
4260 } 4260 }
4261 return res; 4261 return res;
4262 } 4262 }
4263 4263
4264 void 4264 void
4265 _PyDictKeys_DecRef(PyDictKeysObject *keys) 4265 _PyDictKeys_DecRef(PyDictKeysObject *keys)
4266 { 4266 {
4267 DK_DECREF(keys); 4267 DK_DECREF(keys);
4268 } 4268 }
OLDNEW
« no previous file with comments | « Lib/test/test_dictviews.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+