summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-10-31 18:09:11 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-10-31 18:09:11 (GMT)
commitd97eb0d338f3d5746ba4bbd3cfe6e7c28948d41e (patch)
tree4704ed3c037ea0e78224c15767d2ac04777491d9 /Objects/dictobject.c
parent616f8035a8d7cdbb34f8a6a485d8d9d83767d207 (diff)
parent275c848736f1c15efc15b84ced315218ac639899 (diff)
downloadcpython-d97eb0d338f3d5746ba4bbd3cfe6e7c28948d41e.zip
cpython-d97eb0d338f3d5746ba4bbd3cfe6e7c28948d41e.tar.gz
cpython-d97eb0d338f3d5746ba4bbd3cfe6e7c28948d41e.tar.bz2
merge 3.2 (#16345)
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index aef8d10..02dcf7b 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1707,45 +1707,46 @@ dict_fromkeys(PyObject *cls, PyObject *args)
if (d == NULL)
return NULL;
- if (PyDict_CheckExact(d) && PyDict_CheckExact(seq)) {
- PyDictObject *mp = (PyDictObject *)d;
- PyObject *oldvalue;
- Py_ssize_t pos = 0;
- PyObject *key;
- Py_hash_t hash;
-
- if (dictresize(mp, Py_SIZE(seq))) {
- Py_DECREF(d);
- return NULL;
- }
-
- while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) {
- if (insertdict(mp, key, hash, value)) {
+ if (PyDict_CheckExact(d) && PyDict_Size(d) == 0) {
+ if (PyDict_CheckExact(seq)) {
+ PyDictObject *mp = (PyDictObject *)d;
+ PyObject *oldvalue;
+ Py_ssize_t pos = 0;
+ PyObject *key;
+ Py_hash_t hash;
+
+ if (dictresize(mp, Py_SIZE(seq))) {
Py_DECREF(d);
return NULL;
}
- }
- return d;
- }
-
- if (PyDict_CheckExact(d) && PyAnySet_CheckExact(seq)) {
- PyDictObject *mp = (PyDictObject *)d;
- Py_ssize_t pos = 0;
- PyObject *key;
- Py_hash_t hash;
- if (dictresize(mp, PySet_GET_SIZE(seq))) {
- Py_DECREF(d);
- return NULL;
+ while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) {
+ if (insertdict(mp, key, hash, value)) {
+ Py_DECREF(d);
+ return NULL;
+ }
+ }
+ return d;
}
+ if (PyAnySet_CheckExact(seq)) {
+ PyDictObject *mp = (PyDictObject *)d;
+ Py_ssize_t pos = 0;
+ PyObject *key;
+ Py_hash_t hash;
- while (_PySet_NextEntry(seq, &pos, &key, &hash)) {
- if (insertdict(mp, key, hash, value)) {
+ if (dictresize(mp, PySet_GET_SIZE(seq))) {
Py_DECREF(d);
return NULL;
}
+
+ while (_PySet_NextEntry(seq, &pos, &key, &hash)) {
+ if (insertdict(mp, key, hash, value)) {
+ Py_DECREF(d);
+ return NULL;
+ }
+ }
+ return d;
}
- return d;
}
it = PyObject_GetIter(seq);