diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-08 04:28:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-08 04:28:10 +0300 |
commit | 471c0c1afb70e298e8746dcd229d67e242c21fc8 (patch) | |
tree | 8d99785d539bd0e279d94ca2f11176bf3acf3c39 /source/blender/python/generic/py_capi_utils.c | |
parent | e713d76f0e16d379d5993ba6439fef8ba7949783 (diff) |
py-api utf8/filepaths:
in function PyC_UnicodeAsByte(), replace code copied from python with PyUnicode_EncodeFSDefault(), new in py3.2.
Diffstat (limited to 'source/blender/python/generic/py_capi_utils.c')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 3f2fbb1bbec..113a553c6f5 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -212,29 +212,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) 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))); } } |