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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user