Permalink
Browse files

Allow loading python modules with modpython (ex. modname/__init__.py)

Fixes #58
  • Loading branch information...
1 parent 1f16d6d commit d14528b59ef1bae8cc3eed210b396c460e87618b @kylef kylef committed Aug 31, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 modules/modpython/znc.py
View
7 modules/modpython/znc.py
@@ -396,7 +396,7 @@ def find_open(modname):
# './modules/admin.so', ('.so', 'rb', 3))
# x == (<open file './modules/pythontest.py', mode 'U' at
# 0x7fa2dc748d20>, './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 == (<open file './modules/pythontest.py', mode 'U' at 0x7fa2dc748d20>,
# './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)

0 comments on commit d14528b

Please sign in to comment.