Revision: 35395
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35395
Author:   campbellbarton
Date:     2011-03-08 01:28:10 +0000 (Tue, 08 Mar 2011)
Log Message:
-----------
py-api utf8/filepaths:
in function PyC_UnicodeAsByte(), replace code copied from python with 
PyUnicode_EncodeFSDefault(), new in py3.2.

Modified Paths:
--------------
    trunk/blender/source/blender/python/generic/py_capi_utils.c

Modified: trunk/blender/source/blender/python/generic/py_capi_utils.c
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.c 2011-03-08 
01:23:42 UTC (rev 35394)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.c 2011-03-08 
01:28:10 UTC (rev 35395)
@@ -212,29 +212,7 @@
                return PyBytes_AS_STRING(py_str);
        }
        else {
-               /* mostly copied from fileio.c's, fileio_init */
-               PyObject *stringobj;
-               PyObject *u;
-
-               PyErr_Clear();
-               
-               u= PyUnicode_FromObject(py_str); /* coerce into unicode */
-               
-               if (u == NULL)
-                       return NULL;
-
-               stringobj= PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(u), 
PyUnicode_GET_SIZE(u), "surrogateescape");
-               Py_DECREF(u);
-               if (stringobj == NULL)
-                       return NULL;
-               if (!PyBytes_Check(stringobj)) { /* this seems wrong but it 
works fine */
-                       // printf("encoder failed to return bytes\n");
-                       Py_DECREF(stringobj);
-                       return NULL;
-               }
-               *coerce= stringobj;
-
-               return PyBytes_AS_STRING(stringobj);
+               return PyBytes_AS_STRING((*coerce= 
PyUnicode_EncodeFSDefault(py_str)));
        }
 }
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to