Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change ProcessObject to treat lists, tuple and generators as iterator…

…s when serializing
  • Loading branch information...
commit ac1469e1cc6d7ffeb6dc11a17c654ddb513dbcdc 1 parent 44e8588
Igor authored
Showing with 1 addition and 17 deletions.
  1. +1 −17 encoder.c
View
18 encoder.c
@@ -188,7 +188,7 @@ static yajl_gen_status ProcessObject(_YajlEncoder *self, PyObject *object)
if (PyFloat_Check(object)) {
return yajl_gen_double(handle, PyFloat_AsDouble(object));
}
- if (PyList_Check(object)) {
+ if (PyList_Check(object)||PyGen_Check(object)||PyTuple_Check(object)) {
/*
* Recurse and handle the list
*/
@@ -210,22 +210,6 @@ static yajl_gen_status ProcessObject(_YajlEncoder *self, PyObject *object)
return status;
return close_status;
}
- if (PyTuple_Check(object)) {
- /*
- * If we have a tuple, convert to a list
- */
- Py_ssize_t size = PyTuple_Size(object);
- PyObject *converted = PyList_New(size);
- PyObject *item = NULL;
- unsigned int i = 0;
-
- for (; i < size; ++i) {
- item = PyTuple_GetItem(object, i);
- Py_INCREF(item);
- PyList_SET_ITEM(converted, (Py_ssize_t)(i), item);
- }
- return ProcessObject(self, converted);
- }
if (PyDict_Check(object)) {
PyObject *key, *value;
Py_ssize_t position = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.