diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-22 14:49:35 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-22 14:49:35 +0400 |
commit | ebe63b664baa2f4e65643a2535766e5babf9c8a7 (patch) | |
tree | 7b0303d4f8311bd34483c0c7999c4c29b40f2263 /source/blender/python/generic/py_capi_utils.c | |
parent | cac4fde224f3dfb2831779df7b61f819a3564e2d (diff) |
py api - added PyC_UnicodeFromByteAndSize() to match PyUnicode_FromStringAndSize()
also made RNA_property_string_get_alloc() return the length of the new string to avoid having to run strlen on it after.
Diffstat (limited to 'source/blender/python/generic/py_capi_utils.c')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 575495e186e..587ac69071e 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -386,9 +386,9 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) } } -PyObject *PyC_UnicodeFromByte(const char *str) +PyObject *PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size) { - PyObject *result= PyUnicode_FromString(str); + PyObject *result= PyUnicode_FromStringAndSize(str, size); if (result) { /* 99% of the time this is enough but we better support non unicode * chars since blender doesnt limit this */ @@ -397,11 +397,16 @@ PyObject *PyC_UnicodeFromByte(const char *str) else { PyErr_Clear(); /* this means paths will always be accessible once converted, on all OS's */ - result= PyUnicode_DecodeFSDefault(str); + result= PyUnicode_DecodeFSDefaultAndSize(str, size); return result; } } +PyObject *PyC_UnicodeFromByte(const char *str) +{ + return PyC_UnicodeFromByteAndSize(str, strlen(str)); +} + /***************************************************************************** * Description: This function creates a new Python dictionary object. * note: dict is owned by sys.modules["__main__"] module, reference is borrowed |