Merge from 3.2.

The fix was already present in 3.3, but I merged two small changes
recommended by Raymond while I was working on the 2.7 patch to ease
future merges.
This commit is contained in:
Éric Araujo 2011-03-23 04:40:51 +01:00
commit 97054cf0b5
1 changed files with 5 additions and 2 deletions

View File

@ -365,11 +365,12 @@ set_add_entry(register PySetObject *so, setentry *entry)
{ {
register Py_ssize_t n_used; register Py_ssize_t n_used;
PyObject *key = entry->key; PyObject *key = entry->key;
Py_hash_t hash = entry->hash;
assert(so->fill <= so->mask); /* at least one empty slot */ assert(so->fill <= so->mask); /* at least one empty slot */
n_used = so->used; n_used = so->used;
Py_INCREF(key); Py_INCREF(key);
if (set_insert_key(so, key, entry->hash) == -1) { if (set_insert_key(so, key, hash) == -1) {
Py_DECREF(key); Py_DECREF(key);
return -1; return -1;
} }
@ -639,6 +640,7 @@ set_merge(PySetObject *so, PyObject *otherset)
{ {
PySetObject *other; PySetObject *other;
PyObject *key; PyObject *key;
Py_hash_t hash;
register Py_ssize_t i; register Py_ssize_t i;
register setentry *entry; register setentry *entry;
@ -660,10 +662,11 @@ set_merge(PySetObject *so, PyObject *otherset)
for (i = 0; i <= other->mask; i++) { for (i = 0; i <= other->mask; i++) {
entry = &other->table[i]; entry = &other->table[i];
key = entry->key; key = entry->key;
hash = entry->hash;
if (key != NULL && if (key != NULL &&
key != dummy) { key != dummy) {
Py_INCREF(key); Py_INCREF(key);
if (set_insert_key(so, key, entry->hash) == -1) { if (set_insert_key(so, key, hash) == -1) {
Py_DECREF(key); Py_DECREF(key);
return -1; return -1;
} }