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>2010-02-28 01:53:37 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-02-28 01:53:37 +0300
commit5c87e0580f3173fdcd83cc2b4dbe4f5ef2d924a5 (patch)
treebb491cb100638b26e5c1236713e524d6790704e4 /source/blender/python
parent7ab601747af702c43c03ff81e814bb3468dd8c9a (diff)
bugfix [#21247] Controls holding numbers are not zeroed when empty string value is given to them
- dont import math as math and m, just import all members directly. (from math import *) - was adding __builtins__ twice to the namespace - account for unlikely but possibly failier to import math.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_interface.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index ec43118d9fc..4160d56ba25 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -557,24 +557,26 @@ int BPY_button_eval(bContext *C, char *expr, double *value)
PyObject *dict, *mod, *retval;
int error_ret = 0;
- if (!value || !expr || expr[0]=='\0') return -1;
-
+ if (!value || !expr) return -1;
+
+ if(expr[0]=='\0') {
+ *value= 0.0;
+ return error_ret;
+ }
+
bpy_context_set(C, &gilstate);
dict= CreateGlobalDictionary(C, NULL);
-
- /* import some modules: builtins,math*/
- PyDict_SetItemString(dict, "__builtins__", PyEval_GetBuiltins());
mod = PyImport_ImportModule("math");
if (mod) {
PyDict_Merge(dict, PyModule_GetDict(mod), 0); /* 0 - dont overwrite existing values */
-
- /* Only keep for backwards compat! - just import all math into root, they are standard */
- PyDict_SetItemString(dict, "math", mod);
- PyDict_SetItemString(dict, "m", mod);
Py_DECREF(mod);
- }
+ }
+ else { /* highly unlikely but possibly */
+ PyErr_Print();
+ PyErr_Clear();
+ }
retval = PyRun_String(expr, Py_eval_input, dict, dict);