From e3426779df0301ece91b851bba58704e52be2176 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 23 Mar 2006 01:55:14 +0000 Subject: corrected Python object propagation (attribute "py") and adjusted help files small fix enable module packages (module/__init__.py[co]), now also for Max enable compiled-only scripts (without .py) svn path=/trunk/; revision=4751 --- externals/grill/py/source/pybase.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'externals/grill/py/source/pybase.cpp') diff --git a/externals/grill/py/source/pybase.cpp b/externals/grill/py/source/pybase.cpp index f4762fbf..c0f2bc44 100644 --- a/externals/grill/py/source/pybase.cpp +++ b/externals/grill/py/source/pybase.cpp @@ -454,6 +454,7 @@ static bool getmodulesub(const char *mod,char *dir,int len,char *ext) // if dir is current working directory... name points to dir if(dir == name) strcpy(dir,"."); + return name != NULL; #elif FLEXT_SYS == FLEXT_SYS_MAX short path; long type; @@ -570,16 +571,15 @@ bool pybase::ReloadModule() if(module) newmod = PyImport_ReloadModule(module); else { - // search in module path + // search in module path (TODO: check before if module is already present to avoid costly searching) char dir[1024]; - if(getmodulepath(modname.c_str(),dir,sizeof(dir))) { - AddToPath(dir); - newmod = PyImport_ImportModule((char *)modname.c_str()); - } - else { + if(!getmodulepath(modname.c_str(),dir,sizeof(dir))) PyErr_SetString(PyExc_ImportError,"Module not found in path"); - newmod = NULL; - } + else + AddToPath(dir); + + // module could also be loaded ok, even if it's not in the path (e.g. for internal stuff) + newmod = PyImport_ImportModule((char *)modname.c_str()); } } else { -- cgit v1.2.1