merge with trunk at r27259 and commit of a patch by anthony jones to fix msvc (though...
[blender-staging.git] / source / blender / python / intern / bpy_interface.c
index 4ad06e83e9f2fa147f9f6a408dcb806114359ee7..02eebde8a137a0dc5643301c4c2527255811e25a 100644 (file)
@@ -250,7 +250,10 @@ void BPY_start_python( int argc, char **argv )
 
        Py_Initialize(  );
        
+       /*convert argv to wchar_t*/
        // PySys_SetArgv( argc, argv); // broken in py3, not a huge deal
+       
+       /*temporarily set argv*/
        /* sigh, why do python guys not have a char** version anymore? :( */
        {
                int i;
@@ -557,24 +560,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);
        
@@ -631,7 +636,7 @@ void BPY_load_user_modules(bContext *C)
 
        for(text=CTX_data_main(C)->text.first; text; text= text->id.next) {
                if(text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name+2, ".py")) {
-                       if(!(G.fileflags & G_DOSCRIPTLINKS)) {
+                       if(!(G.f & G_SCRIPT_AUTOEXEC)) {
                                printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name+2);
                        }
                        else {