[Python-checkins] cpython: Issue 18772: Restore set dummy object back to unicode and restore the identity
raymond.hettinger
python-checkins at python.org
Wed Aug 21 07:28:41 CEST 2013
http://hg.python.org/cpython/rev/be29efa60b68
changeset: 85287:be29efa60b68
parent: 85284:afb1b4797419
user: Raymond Hettinger <python at rcn.com>
date: Tue Aug 20 22:28:24 2013 -0700
summary:
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.
files:
Objects/setobject.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Objects/setobject.c b/Objects/setobject.c
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -95,7 +95,7 @@
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 @@
}
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 @@
}
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 @@
PySetObject *so = NULL;
if (dummy == NULL) { /* Auto-initialize dummy */
- dummy = _PyObject_New(&PyBaseObject_Type);
+ dummy = PyUnicode_FromString("<dummy key>");
if (dummy == NULL)
return NULL;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list