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:
authorMichel Selten <michel@mselten.demon.nl>2003-04-08 23:54:14 +0400
committerMichel Selten <michel@mselten.demon.nl>2003-04-08 23:54:14 +0400
commitec669df6eec3188938d9d84dd4666eac8b5aa1d1 (patch)
tree39985e13620956eb4e9d708b2d880ed8b03d0bd6 /source/blender/python/BPY_interface.c
parent0850182872fef788d8cf128f3a5901dca142fa8f (diff)
The following updates have been contributed by Willian P. Germano:
* Implemented BPY_end_python function. * Implemented error handling. This results in rerunning a script after an error has occurred. No need to restart blender anymore. * Camera module supports dir() * variable assignment now calls the Python equivalent function - this has type checking and should be safer now. * Implemented the Lamp module. Used the Camera module as a template. * Implemented the Image module. * Added EXPP_ClampFloat and EXPP_intError functions to gen_utils.[ch] * Implemented 'constant' object.
Diffstat (limited to 'source/blender/python/BPY_interface.c')
-rw-r--r--source/blender/python/BPY_interface.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index d205f790f90..3ee3178b07d 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -24,7 +24,7 @@
*
* This is a new part of Blender.
*
- * Contributor(s): Michel Selten
+ * Contributor(s): Michel Selten, Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -96,12 +96,12 @@ void BPY_start_python(void)
}
/*****************************************************************************/
-/* Description: */
-/* Notes: Not implemented yet */
+/* Description: This function will terminate the Python interpreter */
/*****************************************************************************/
void BPY_end_python(void)
{
printf ("In BPY_end_python\n");
+ Py_Finalize();
return;
}
@@ -145,6 +145,15 @@ struct _object *BPY_txt_do_python(struct SpaceText* st)
/* dict = newGlobalDictionary(); */
ret = RunPython (st->text, dict);
+ /* If errors have occurred, set the error filename to the name of the
+ script.
+ */
+ if (!ret)
+ {
+ sprintf(g_script_error.filename, "%s", st->text->id.name+2);
+ return NULL;
+ }
+
return dict;
}
@@ -307,6 +316,17 @@ PyObject * RunPython(Text *text, PyObject *globaldict)
buf = txt_to_buf(text);
ret = PyRun_String (buf, Py_file_input, globaldict, globaldict);
+ if (!ret)
+ {
+ /* an exception was raised, handle it here */
+ PyErr_Print(); /* this function also clears the error
+ indicator */
+ }
+ else
+ {
+ PyErr_Clear(); /* seems necessary, at least now */
+ }
+
MEM_freeN (buf);
return ret;
}