[Bf-python] exceptions in scriptlinks
Yann Vernier
yann at algonet.se
Sun Jun 22 19:46:40 CEST 2003
I was wondering where the unhandled exceptions went. Turns out they went
nowhere and everything else went into a memory leak. Here's a little
patch for that, I believe.
--
PGP fingerprint = 9242 DC15 2502 FEAB E15F 84C6 D538 EC09 5380 5746
-------------- next part --------------
Index: BPY_interface.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/BPY_interface.c,v
retrieving revision 1.12
diff -u -b -r1.12 BPY_interface.c
--- BPY_interface.c 14 Jun 2003 10:09:59 -0000 1.12
+++ BPY_interface.c 22 Jun 2003 17:44:59 -0000
@@ -352,7 +354,7 @@
{
ScriptLink * scriptlink;
int index;
- PyObject * dict;
+ PyObject * dict, *ret;
printf ("In BPY_do_pyscript(id=%s, event=%d)\n",id->name, event);
@@ -368,8 +370,14 @@
(scriptlink->scripts[index] != NULL))
{
dict = CreateGlobalDictionary();
- RunPython ((Text*) scriptlink->scripts[index], dict);
+ ret = RunPython ((Text*) scriptlink->scripts[index], dict);
ReleaseGlobalDictionary (dict);
+ if (!ret) { /* Failed execution of the script */
+ BPY_Err_Handle((Text*) scriptlink->scripts[index]);
+ BPY_end_python();
+ BPY_start_python();
+ }
+ else Py_DECREF(ret);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20030622/97835673/attachment.sig>
More information about the Bf-python
mailing list