From 7060250b7583ad9cd20007b6fda5dcf068d55cbe Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Thu, 22 Mar 2012 15:12:26 +0100 Subject: cython: Fix broken String plist handling in Python --- cython/plist.pyx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cython') diff --git a/cython/plist.pyx b/cython/plist.pyx index 4732d0f..3716a9c 100644 --- a/cython/plist.pyx +++ b/cython/plist.pyx @@ -283,8 +283,8 @@ cdef class String(Node): if isinstance(value, unicode): utf8_data = value.encode('utf-8') elif (PY_MAJOR_VERSION < 3) and isinstance(value, str): - value.decode('ascii') # trial decode - utf8_data = value.decode('ascii') + value.encode('ascii') # trial decode + utf8_data = value.encode('ascii') else: raise ValueError("Requires unicode input, got %s" % type(value)) c_utf8_data = utf8_data @@ -319,8 +319,8 @@ cdef class String(Node): if isinstance(value, unicode): utf8_data = value.encode('utf-8') elif (PY_MAJOR_VERSION < 3) and isinstance(value, str): - value.decode('ascii') # trial decode - utf8_data = value.decode('ascii') + value.encode('ascii') # trial decode + utf8_data = value.encode('ascii') else: raise ValueError("Requires unicode input, got %s" % type(value)) c_utf8_data = utf8_data @@ -331,7 +331,7 @@ cdef class String(Node): char* c_value = NULL plist_get_string_val(self._c_node, &c_value) try: - return cpython.PyUnicode_DecodeUTF8(c_value, libc.stdlib.strlen(c_value), 'strict') + return cpython.PyUnicode_DecodeUTF8(c_value, len(c_value), 'strict') finally: libc.stdlib.free(c_value) -- cgit v1.1-32-gdbae