[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53939] trunk/blender/source/blender/ python/intern/bpy_app_translations.c: minor changes to _build_translations_cache(), remove unneeded NULL checks and use slightly different funcs for getting strings .
Campbell Barton
ideasman42 at gmail.com
Mon Jan 21 03:40:42 CET 2013
Revision: 53939
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53939
Author: campbellbarton
Date: 2013-01-21 02:40:36 +0000 (Mon, 21 Jan 2013)
Log Message:
-----------
minor changes to _build_translations_cache(), remove unneeded NULL checks and use slightly different funcs for getting strings.
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_app_translations.c
Modified: trunk/blender/source/blender/python/intern/bpy_app_translations.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_app_translations.c 2013-01-21 02:30:40 UTC (rev 53938)
+++ trunk/blender/source/blender/python/intern/bpy_app_translations.c 2013-01-21 02:40:36 UTC (rev 53939)
@@ -177,14 +177,22 @@
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_GetItem(pykey, 1);
- if (tmp && PyUnicode_Check(tmp) && !PyUnicode_READY(tmp)) {
- msgid = (const char *)PyUnicode_AsUTF8(tmp);
+
+ tmp = PyTuple_GET_ITEM(pykey, 0);
+ if (PyUnicode_Check(tmp)) {
+ msgctxt = _PyUnicode_AsString(tmp);
}
+ tmp = PyTuple_GET_ITEM(pykey, 1);
+ if (PyUnicode_Check(tmp)) {
+ msgid = _PyUnicode_AsString(tmp);
+ }
if (!(msgctxt && msgid)) {
continue;
@@ -197,9 +205,7 @@
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)));
}
}
}
More information about the Bf-blender-cvs
mailing list