Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-01-21 06:40:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-01-21 06:40:36 +0400
commitd05f46c12d36492e8bc6690b41065f5226e92e2b (patch)
treeda0a76dc971996a0b572fe9f07e4a93d9189275e /source/blender/python
parent38cee985bb6d6a45fe59cc539dfa9cd6412b6f36 (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')
-rw-r--r--source/blender/python/intern/bpy_app_translations.c24
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)));
}
}
}