Skip to content

Commit 6c08e8f

Browse files
committed
debugged enchilada importer
1 parent 2206344 commit 6c08e8f

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

enchilada_import.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,15 @@ def load_module(self,fullname):
113113
#print "__LOADING ",fullname,pathname
114114

115115

116+
ignore, ext = os.path.splitext(pathname)
117+
target_path = [os.path.dirname(pathname)]
118+
119+
subname = fullname.split(".")[-1]
120+
116121
if os.path.isfile(pathname):
117122
# (If we're loading a PY_SOURCE file, the interpreter will
118123
# automatically check for a compiled (.py[c|o]) file.)
119124

120-
ignore, ext = os.path.splitext(pathname)
121-
target_path = [os.path.dirname(pathname)]
122-
123-
subname = fullname.split(".")[-1]
124125

125126
if ext == '.so':
126127
file, filename, stuff = imp.find_module(subname, target_path)
@@ -133,22 +134,14 @@ def load_module(self,fullname):
133134
file.close()
134135
# Not a file, so it's a package directory
135136
else:
136-
mod = mpiimporter.load_module(fullname,None,pathname,desc)
137-
mod.__loader__ = self
138-
return mod
139-
137+
file, filename, stuff = mpiimporter.find_module(subname, target_path)
138+
mod = mpiimporter.load_module(fullname,file,pathname,desc)
140139

141-
mod = mpiimporter.load_module(fullname, self.file, self.filename, self.stuff)
142-
if self.file:
143-
self.file.close()
144-
mod.__loader__ = self # for introspection
145-
return mod
146-
147-
140+
mod.__loader__ = self # for introspection
141+
return mod
148142
raise ImportError("This shouldn't happen!")
149143

150144

151-
152145
# Build up a dict of modules (including package directories) found in a
153146
# directory. If this directory has been prepended to the path, we need to
154147
# overwrite any conflicting entries in the cache. To make sure precedence

0 commit comments

Comments
 (0)