summaryrefslogtreecommitdiffstats
path: root/cython
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2012-03-22 15:12:26 +0100
committerGravatar Martin Szulecki2012-03-22 15:12:26 +0100
commit7060250b7583ad9cd20007b6fda5dcf068d55cbe (patch)
treecea14cb2c218e6ec8b4ab225138e68628443fb78 /cython
parentd01bdae204ceaf2bd658d4cc303e79adb1e7e3a8 (diff)
downloadlibplist-7060250b7583ad9cd20007b6fda5dcf068d55cbe.tar.gz
libplist-7060250b7583ad9cd20007b6fda5dcf068d55cbe.tar.bz2
cython: Fix broken String plist handling in Python
Diffstat (limited to 'cython')
-rw-r--r--cython/plist.pyx10
1 files changed, 5 insertions, 5 deletions
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):
283 if isinstance(value, unicode): 283 if isinstance(value, unicode):
284 utf8_data = value.encode('utf-8') 284 utf8_data = value.encode('utf-8')
285 elif (PY_MAJOR_VERSION < 3) and isinstance(value, str): 285 elif (PY_MAJOR_VERSION < 3) and isinstance(value, str):
286 value.decode('ascii') # trial decode 286 value.encode('ascii') # trial decode
287 utf8_data = value.decode('ascii') 287 utf8_data = value.encode('ascii')
288 else: 288 else:
289 raise ValueError("Requires unicode input, got %s" % type(value)) 289 raise ValueError("Requires unicode input, got %s" % type(value))
290 c_utf8_data = utf8_data 290 c_utf8_data = utf8_data
@@ -319,8 +319,8 @@ cdef class String(Node):
319 if isinstance(value, unicode): 319 if isinstance(value, unicode):
320 utf8_data = value.encode('utf-8') 320 utf8_data = value.encode('utf-8')
321 elif (PY_MAJOR_VERSION < 3) and isinstance(value, str): 321 elif (PY_MAJOR_VERSION < 3) and isinstance(value, str):
322 value.decode('ascii') # trial decode 322 value.encode('ascii') # trial decode
323 utf8_data = value.decode('ascii') 323 utf8_data = value.encode('ascii')
324 else: 324 else:
325 raise ValueError("Requires unicode input, got %s" % type(value)) 325 raise ValueError("Requires unicode input, got %s" % type(value))
326 c_utf8_data = utf8_data 326 c_utf8_data = utf8_data
@@ -331,7 +331,7 @@ cdef class String(Node):
331 char* c_value = NULL 331 char* c_value = NULL
332 plist_get_string_val(self._c_node, &c_value) 332 plist_get_string_val(self._c_node, &c_value)
333 try: 333 try:
334 return cpython.PyUnicode_DecodeUTF8(c_value, libc.stdlib.strlen(c_value), 'strict') 334 return cpython.PyUnicode_DecodeUTF8(c_value, len(c_value), 'strict')
335 finally: 335 finally:
336 libc.stdlib.free(c_value) 336 libc.stdlib.free(c_value)
337 337