When converting a tuple to a list, the count needs to be incremented on the borrowed reference
http://github.com/rtyler/py-yajl/issues#issue/11 Change-Id: I54adeaf992d041f43b8d1c9c8eb3fbe957b85826
This commit is contained in:
parent
dff262de24
commit
836ea060ac
|
@ -181,10 +181,13 @@ static yajl_gen_status ProcessObject(_YajlEncoder *self, PyObject *object)
|
|||
*/
|
||||
Py_ssize_t size = PyTuple_Size(object);
|
||||
PyObject *converted = PyList_New(size);
|
||||
PyObject *item = NULL;
|
||||
unsigned int i = 0;
|
||||
|
||||
for (; i < size; ++i) {
|
||||
PyList_SET_ITEM(converted, (Py_ssize_t)(i), PyTuple_GetItem(object, i));
|
||||
item = PyTuple_GetItem(object, i);
|
||||
Py_INCREF(item);
|
||||
PyList_SET_ITEM(converted, (Py_ssize_t)(i), item);
|
||||
}
|
||||
return ProcessObject(self, converted);
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import yajl
|
||||
import sys
|
||||
|
||||
for i, l in enumerate(sys.stdin):
|
||||
l = l.rstrip('\n').split('\t')
|
||||
d = yajl.dumps(tuple(l))
|
||||
print i,
|
Loading…
Reference in New Issue