summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-10-31 18:10:04 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-10-31 18:10:04 (GMT)
commit7503e085882501c7a887d67b65f19b5ee9bfa361 (patch)
tree2aa3c9d1151deb8577570e55fea680cca0576c7f /Objects
parent9c3f5031a9c3e0557cf28e72fa1f74f23b9144f6 (diff)
parentd97eb0d338f3d5746ba4bbd3cfe6e7c28948d41e (diff)
downloadcpython-7503e085882501c7a887d67b65f19b5ee9bfa361.zip
cpython-7503e085882501c7a887d67b65f19b5ee9bfa361.tar.gz
cpython-7503e085882501c7a887d67b65f19b5ee9bfa361.tar.bz2
merge 3.3 (#16345)
Diffstat (limited to 'Objects')
-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);