[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12051] trunk/blender/source/blender/ python/BPY_interface.c: when importing sys failed blender could crash on startup.
Campbell Barton
cbarton at metavr.com
Mon Sep 17 06:46:59 CEST 2007
Revision: 12051
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12051
Author: campbellbarton
Date: 2007-09-17 06:46:58 +0200 (Mon, 17 Sep 2007)
Log Message:
-----------
when importing sys failed blender could crash on startup. Blender will now exit with an error rather then crashing.
Modified Paths:
--------------
trunk/blender/source/blender/python/BPY_interface.c
Modified: trunk/blender/source/blender/python/BPY_interface.c
===================================================================
--- trunk/blender/source/blender/python/BPY_interface.c 2007-09-16 23:19:02 UTC (rev 12050)
+++ trunk/blender/source/blender/python/BPY_interface.c 2007-09-17 04:46:58 UTC (rev 12051)
@@ -273,25 +273,32 @@
void syspath_append( char *dirname )
{
- PyObject *mod_sys, *dict, *path, *dir;
-
+ PyObject *mod_sys= NULL, *dict= NULL, *path= NULL, *dir= NULL;
+ short ok=1;
PyErr_Clear( );
dir = Py_BuildValue( "s", dirname );
mod_sys = PyImport_ImportModule( "sys" ); /* new ref */
- dict = PyModule_GetDict( mod_sys ); /* borrowed ref */
- path = PyDict_GetItemString( dict, "path" ); /* borrowed ref */
+
+ if (mod_sys) {
+ dict = PyModule_GetDict( mod_sys ); /* borrowed ref */
+ path = PyDict_GetItemString( dict, "path" ); /* borrowed ref */
+ if ( !PyList_Check( path ) ) {
+ ok = 0;
+ }
+ } else {
+ /* cant get the sys module */
+ ok = 0;
+ }
- if( !PyList_Check( path ) )
- return;
+ if (ok && PyList_Append( path, dir ) != 0)
+ ok = 0; /* append failed */
- PyList_Append( path, dir );
+ if( (ok==0) || PyErr_Occurred( ) )
+ Py_FatalError( "could import or build sys.path, can't continue" );
- if( PyErr_Occurred( ) )
- Py_FatalError( "could not build sys.path" );
-
- Py_DECREF( mod_sys );
+ Py_XDECREF( mod_sys );
}
void init_syspath( int first_time )
More information about the Bf-blender-cvs
mailing list