diff options
author | Stephen Swaney <sswaney@centurytel.net> | 2003-10-19 10:26:32 +0400 |
---|---|---|
committer | Stephen Swaney <sswaney@centurytel.net> | 2003-10-19 10:26:32 +0400 |
commit | c19d84f89e442a283ea3dcd4d80fb113b52d10bd (patch) | |
tree | 5b269e45f60d255bb6af97d3cde1276cb2f763cd /source/blender/python/BPY_interface.c | |
parent | 56ad0d31b94bf7409c798ac7ef9ee04556b81e6e (diff) |
Fix unchecked pointer reference when adding sitedirs to sys.path.
This is a bugfix against the 2.28c release.
Diffstat (limited to 'source/blender/python/BPY_interface.c')
-rw-r--r-- | source/blender/python/BPY_interface.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 7bf5351731b..6a217005fce 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -199,31 +199,47 @@ void init_syspath(void) syspath_append(p); /* append to module search path */ } - /* sds */ - /* bring in the site module so we can add site-package dirs to sys.path */ + /* + * bring in the site module so we can add + * site-package dirs to sys.path + */ + mod = PyImport_ImportModule("site"); /* new ref */ if (mod) { PyObject* item; - int size, index; + int size = 0; + int index; /* get the value of 'sitedirs' from the module */ + + /* the ref man says GetDict() never fails!!! */ d = PyModule_GetDict (mod); /* borrowed ref */ p = PyDict_GetItemString (d, "sitedirs"); /* borrowed ref */ - /* append each item in sitedirs list to path */ - size = PyList_Size (p); + if( p ) { /* we got our string */ + /* append each item in sitedirs list to path */ + size = PyList_Size (p); - for (index = 0; index < size; index++) { - item = PySequence_GetItem (p, index); /* new ref */ - syspath_append (item); + for (index = 0; index < size; index++) { + item = PySequence_GetItem (p, index); /* new ref */ + if( item ) + syspath_append (item); + } } - Py_DECREF(mod); } - else PyErr_Clear(); + else { /* import 'site' failed */ + PyErr_Clear(); + printf("sys_init:warning - no sitedirs added from site module.\n"); + } + + /* + * initialize the sys module + * set sys.executable to the Blender exe + * set argv[0] to the Blender exe + */ - /* set sys.executable to the Blender exe */ mod = PyImport_ImportModule("sys"); /* new ref */ if (mod) { |