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>2009-06-14 16:53:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-06-14 16:53:47 +0400
commit8ab7fbe79563895b38bcfc50625e19fa2b38f843 (patch)
treeb161a037474a34fabcbcaa4dc80600bf28bf536d /source/blender/python/intern/bpy_interface.c
parentc3c38155ad2aca369fa956b2251ed41c749942cc (diff)
Blender/Python API
Send the full python stack trace to the reporting api, added BPY_exception_buffer which temporarily overrides sys.stdout and sys.stderr to get the output (uses the io module in py3 StringIO in py2 to avoid writing into a real file), pity the Py/C api has no function to do this. fix for crash when showing menu's that have no items.
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r--source/blender/python/intern/bpy_interface.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 7b3a67ebff5..22336bd4f71 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -150,7 +150,7 @@ void BPY_end_python( void )
}
/* Can run a file or text block */
-int BPY_run_python_script( bContext *C, const char *fn, struct Text *text )
+int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struct ReportList *reports)
{
PyObject *py_dict, *py_result;
PyGILState_STATE gilstate;
@@ -178,7 +178,7 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text )
MEM_freeN( buf );
if( PyErr_Occurred( ) ) {
- PyErr_Print(); PyErr_Clear();
+ BPy_errors_to_report(reports);
BPY_free_compiled_text( text );
PyGILState_Release(gilstate);
return 0;
@@ -194,7 +194,7 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text )
}
if (!py_result) {
- PyErr_Print(); PyErr_Clear();
+ BPy_errors_to_report(reports);
} else {
Py_DECREF( py_result );
}
@@ -221,7 +221,7 @@ static void exit_pydraw( SpaceScript * sc, short err )
script = sc->script;
if( err ) {
- PyErr_Print(); PyErr_Clear();
+ BPy_errors_to_report(NULL); // TODO, reports
script->flags = 0; /* mark script struct for deletion */
SCRIPT_SET_NULL(script);
script->scriptname[0] = '\0';
@@ -250,7 +250,7 @@ static int bpy_run_script_init(bContext *C, SpaceScript * sc)
return 0;
if (sc->script->py_draw==NULL && sc->script->scriptname[0] != '\0')
- BPY_run_python_script(C, sc->script->scriptname, NULL);
+ BPY_run_python_script(C, sc->script->scriptname, NULL, NULL);
if (sc->script->py_draw==NULL)
return 0;
@@ -329,7 +329,7 @@ int BPY_run_python_script_space(const char *modulename, const char *func)
}
if (!py_result) {
- PyErr_Print(); PyErr_Clear();
+ BPy_errors_to_report(NULL); // TODO - reports
} else
Py_DECREF( py_result );
@@ -410,7 +410,7 @@ void BPY_run_ui_scripts(bContext *C, int reload)
if(mod) {
Py_DECREF(mod); /* could be NULL from reloading */
} else {
- PyErr_Print(); PyErr_Clear();
+ BPy_errors_to_report(NULL); // TODO - reports
fprintf(stderr, "unable to import \"%s\" %s/%s\n", path, dirname, de->d_name);
}
}
@@ -530,7 +530,7 @@ static float pydriver_error(ChannelDriver *driver)
driver->flag |= DRIVER_FLAG_INVALID; /* py expression failed */
fprintf(stderr, "\nError in Driver: The following Python expression failed:\n\t'%s'\n\n", driver->expression);
- PyErr_Print(); PyErr_Clear();
+ BPy_errors_to_report(NULL); // TODO - reports
return 0.0f;
}
@@ -589,7 +589,7 @@ float BPY_pydriver_eval (ChannelDriver *driver)
}
fprintf(stderr, "\tBPY_pydriver_eval() - couldn't add variable '%s' to namespace \n", dtar->name);
- PyErr_Print(); PyErr_Clear();
+ BPy_errors_to_report(NULL); // TODO - reports
}
}