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>2007-09-17 08:46:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-09-17 08:46:58 +0400
commit976a0424e1edd9dd83b8ff8427d2b7c69f846a2a (patch)
tree694d4a4c508666f7fcfaecfdcf3282b815dd6355 /source/blender/python/BPY_interface.c
parent90daa8f81126a86f2cd419a6288b5f0b097d478b (diff)
when importing sys failed blender could crash on startup. Blender will now exit with an error rather then crashing.
Diffstat (limited to 'source/blender/python/BPY_interface.c')
-rw-r--r--source/blender/python/BPY_interface.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index 2b723f2444d..97d9f221ab9 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -273,25 +273,32 @@ void BPY_end_python( void )
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( !PyList_Check( path ) )
- return;
+
+ 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;
+ }
- PyList_Append( path, dir );
+ if (ok && PyList_Append( path, dir ) != 0)
+ ok = 0; /* append failed */
- if( PyErr_Occurred( ) )
- Py_FatalError( "could not build sys.path" );
+ if( (ok==0) || PyErr_Occurred( ) )
+ Py_FatalError( "could import or build sys.path, can't continue" );
- Py_DECREF( mod_sys );
+ Py_XDECREF( mod_sys );
}
void init_syspath( int first_time )