mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
merge 3.2 (#16345)
This commit is contained in:
commit
d97eb0d338
3 changed files with 41 additions and 29 deletions
|
@ -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 (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;
|
||||
}
|
||||
|
||||
while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) {
|
||||
if (insertdict(mp, key, hash, value)) {
|
||||
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)) {
|
||||
Py_DECREF(d);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
if (PyAnySet_CheckExact(seq)) {
|
||||
PyDictObject *mp = (PyDictObject *)d;
|
||||
Py_ssize_t pos = 0;
|
||||
PyObject *key;
|
||||
Py_hash_t hash;
|
||||
|
||||
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 (_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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue