Commits

Ronald Oussoren committed 33d4d35

Fix unicode issues with python 3.3

  • Participants
  • Parent commits fbaff80

Comments (0)

Files changed (2)

pyobjc-core/Modules/objc/libffi_support.m

 							} else {
 								count = methinfo->argtype[i].arrayArg;
 							}
-
+							
 							if (*resttype == _C_UNICHAR) {
+								
 								int byteorder = 0;
 								v = PyUnicode_DecodeUTF16(
 									arg, count*2, NULL, &byteorder);

pyobjc-core/Modules/objc/objc_util.m

 		if (*bufobj == NULL) {
 			return -1;
 		}
-		*array = PyBytes_AsString(*bufobj);
-		return SHOULD_IGNORE;
+
+		/* XXX: Update API protocol to make the extra copy not necessary 
+		 * Cannot use the code at the end because 'buffer' is assumed to be
+		 * the value to return to the python caller.
+		 */
+		*array = PyMem_Malloc(PyBytes_Size(*bufobj));
+		memcpy(*array, PyBytes_AsString(*bufobj), PyBytes_Size(*bufobj));
+		Py_DECREF(*bufobj);
+		*bufobj = NULL;
+		return SHOULD_FREE;
+
+		/* *array = PyBytes_AsString(*bufobj); return SHOULD_IGNORE*/
 
 #else	/* Python before 3.3 */
 		if (writable) {