From d14528b59ef1bae8cc3eed210b396c460e87618b Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Wed, 31 Aug 2011 17:17:19 +0000 Subject: [PATCH] Allow loading python modules with modpython (ex. modname/__init__.py) Fixes #58 --- modules/modpython/znc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/modpython/znc.py b/modules/modpython/znc.py index 26e6dd60..0450d55f 100644 --- a/modules/modpython/znc.py +++ b/modules/modpython/znc.py @@ -396,7 +396,7 @@ def find_open(modname): # './modules/admin.so', ('.so', 'rb', 3)) # x == (, './modules/pythontest.py', ('.py', 'U', 1)) - if x[0] is None: + if x[0] is None and x[2][2] != imp.PKG_DIRECTORY: # the same continue if x[2][0] == '.so': @@ -416,7 +416,8 @@ def find_open(modname): try: pymodule = imp.load_module(modname, *x) finally: - x[0].close() + if x[0]: + x[0].close() return (pymodule, d[1]) else: # nothing found @@ -548,7 +549,7 @@ def get_mod_info_path(path, modname, modinfo): # './modules/admin.so', ('.so', 'rb', 3)) # x == (, # './modules/pythontest.py', ('.py', 'U', 1)) - if x[0] is None: + if x[0] is None and x[2][2] != imp.PKG_DIRECTORY: return 0 try: pymodule = imp.load_module(modname, *x)