Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Encode keys properly for Python 3

Change-Id: I6f931788c6d9665bba98083335157318807c6a63
  • Loading branch information...
commit 9fbc54223959c54db001edea62fd5438d43d054a 1 parent f40427c
@rtyler authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 encoder.c
View
10 encoder.c
@@ -133,7 +133,17 @@ static yajl_gen_status ProcessObject(_YajlEncoder *self, PyObject *object)
(PyInt_Check(key)) ||
#endif
(PyLong_Check(key)) ) {
+
+ /*
+ * Performing the conversion separately for Python 2
+ * and Python 3 to ensure we consistently generate
+ * unicode strings in both versions
+ */
+#ifdef IS_PYTHON3
+ newKey = PyObject_Str(key);
+#else
newKey = PyObject_Unicode(key);
+#endif
}
status = ProcessObject(self, newKey);
Please sign in to comment.
Something went wrong with that request. Please try again.