summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2015-05-03 02:37:13 (GMT)
committerBenjamin Peterson <benjamin@python.org>2015-05-03 02:37:13 (GMT)
commit88abdef02b33774e7d675a7cc47a9b2567a41921 (patch)
tree39002cc8696adb52a8e454c470f528b8d34901f4 /Modules
parentc9083bf1a14d9949c07804123712d2a18566fe62 (diff)
parent122f4b1bda8262ace6aa021935e8c605a17c3748 (diff)
downloadcpython-88abdef02b33774e7d675a7cc47a9b2567a41921.zip
cpython-88abdef02b33774e7d675a7cc47a9b2567a41921.tar.gz
cpython-88abdef02b33774e7d675a7cc47a9b2567a41921.tar.bz2
merge 3.4 (#24094)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_json.c31
1 files changed, 3 insertions, 28 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 3a60243..e2e8bf3 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -1663,36 +1663,11 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc,
*/
}
- if (PyObject_IsTrue(s->sort_keys)) {
- /* First sort the keys then replace them with (key, value) tuples. */
- Py_ssize_t i, nitems;
- items = PyMapping_Keys(dct);
- if (items == NULL)
- goto bail;
- if (!PyList_Check(items)) {
- PyErr_SetString(PyExc_ValueError, "keys must return list");
- goto bail;
- }
- if (PyList_Sort(items) < 0)
- goto bail;
- nitems = PyList_GET_SIZE(items);
- for (i = 0; i < nitems; i++) {
- PyObject *key, *value;
- key = PyList_GET_ITEM(items, i);
- value = PyDict_GetItem(dct, key);
- item = PyTuple_Pack(2, key, value);
- if (item == NULL)
- goto bail;
- PyList_SET_ITEM(items, i, item);
- item = NULL;
- Py_DECREF(key);
- }
- }
- else {
- items = PyMapping_Items(dct);
- }
+ items = PyMapping_Items(dct);
if (items == NULL)
goto bail;
+ if (PyObject_IsTrue(s->sort_keys) && PyList_Sort(items) < 0)
+ goto bail;
it = PyObject_GetIter(items);
Py_DECREF(items);
if (it == NULL)