summaryrefslogtreecommitdiffstats
path: root/Objects/setobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2013-08-21 05:28:24 (GMT)
committerRaymond Hettinger <python@rcn.com>2013-08-21 05:28:24 (GMT)
commitae9e616a00e0a288c31dc053db40353302823e88 (patch)
tree2aa78daeeb0535e22b040221a4ef63c00dac6bd6 /Objects/setobject.c
parent0688897f056283d497b3e19a7a9806bcdd583494 (diff)
downloadcpython-ae9e616a00e0a288c31dc053db40353302823e88.zip
cpython-ae9e616a00e0a288c31dc053db40353302823e88.tar.gz
cpython-ae9e616a00e0a288c31dc053db40353302823e88.tar.bz2
Issue 18772: Restore set dummy object back to unicode and restore the identity checks in lookkey().
The Gdb prettyprint plugin depended on the dummy object being displayable. Other solutions besides a unicode object are possible. For now, get it back up and running. The identity checks in lookkey() need to be there to prevent the dummy object from leaking through Py_RichCompareBool() into user code in the rare circumstance where the dummy's hash value exactly matches the hash value of the actual key being looked up.
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r--Objects/setobject.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 6327a31..3d9deac 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -95,7 +95,7 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
entry = &table[i];
if (entry->key == NULL || entry->key == key)
return entry;
- if (entry->hash == hash) {
+ if (entry->hash == hash && entry->key != dummy) {
startkey = entry->key;
Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
@@ -127,7 +127,7 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
}
if (entry->key == key)
break;
- if (entry->hash == hash) {
+ if (entry->hash == hash && entry->key != dummy) {
startkey = entry->key;
Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
@@ -157,7 +157,7 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
}
if (entry->key == key)
break;
- if (entry->hash == hash) {
+ if (entry->hash == hash && entry->key != dummy) {
startkey = entry->key;
Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
@@ -1090,7 +1090,7 @@ make_new_set(PyTypeObject *type, PyObject *iterable)
PySetObject *so = NULL;
if (dummy == NULL) { /* Auto-initialize dummy */
- dummy = _PyObject_New(&PyBaseObject_Type);
+ dummy = PyUnicode_FromString("<dummy key>");
if (dummy == NULL)
return NULL;
}