diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-21 06:40:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-21 06:40:36 +0400 |
commit | d05f46c12d36492e8bc6690b41065f5226e92e2b (patch) | |
tree | da0a76dc971996a0b572fe9f07e4a93d9189275e /source/blender/python/intern/bpy_app_translations.c | |
parent | 38cee985bb6d6a45fe59cc539dfa9cd6412b6f36 (diff) |
minor changes to _build_translations_cache(), remove unneeded NULL checks and use slightly different funcs for getting strings.
Diffstat (limited to 'source/blender/python/intern/bpy_app_translations.c')
-rw-r--r-- | source/blender/python/intern/bpy_app_translations.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 6e9f12ec529..8a7140cf792 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -177,13 +177,21 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale) PyObject *tmp; const char *msgctxt = NULL, *msgid = NULL; - tmp = PyTuple_GetItem(pykey, 0); - if (tmp && PyUnicode_Check(tmp) && !PyUnicode_READY(tmp)) { - msgctxt = (const char *)PyUnicode_AsUTF8(tmp); + if ((PyTuple_CheckExact(pykey) == false) || + (PyTuple_GET_SIZE(pykey) != 2) || + (PyUnicode_Check(trans) == false)) + { + /* TODO, we should error here */ + continue; + } + + tmp = PyTuple_GET_ITEM(pykey, 0); + if (PyUnicode_Check(tmp)) { + msgctxt = _PyUnicode_AsString(tmp); } - tmp = PyTuple_GetItem(pykey, 1); - if (tmp && PyUnicode_Check(tmp) && !PyUnicode_READY(tmp)) { - msgid = (const char *)PyUnicode_AsUTF8(tmp); + tmp = PyTuple_GET_ITEM(pykey, 1); + if (PyUnicode_Check(tmp)) { + msgid = _PyUnicode_AsString(tmp); } if (!(msgctxt && msgid)) { @@ -197,9 +205,7 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale) continue; } - if (trans && PyUnicode_Check(trans) && !PyUnicode_READY(trans)) { - BLI_ghash_insert(_translations_cache, key, BLI_strdup((const char *)PyUnicode_AsUTF8(trans))); - } + BLI_ghash_insert(_translations_cache, key, BLI_strdup(_PyUnicode_AsString(trans))); } } } |