Kaydet (Commit) 2ea05098 authored tarafından Guido van Rossum's avatar Guido van Rossum

close module file after loading

üst be0a8a60
...@@ -133,6 +133,7 @@ class BasicModuleLoader(_Verbose): ...@@ -133,6 +133,7 @@ class BasicModuleLoader(_Verbose):
def load_module(self, name, stuff): def load_module(self, name, stuff):
file, filename, (suff, mode, type) = stuff file, filename, (suff, mode, type) = stuff
try:
if type == BUILTIN_MODULE: if type == BUILTIN_MODULE:
return imp.init_builtin(name) return imp.init_builtin(name)
if type == FROZEN_MODULE: if type == FROZEN_MODULE:
...@@ -143,6 +144,8 @@ class BasicModuleLoader(_Verbose): ...@@ -143,6 +144,8 @@ class BasicModuleLoader(_Verbose):
return imp.load_source(name, filename, file) return imp.load_source(name, filename, file)
if type == PY_COMPILED: if type == PY_COMPILED:
return imp.load_compiled(name, filename, file) return imp.load_compiled(name, filename, file)
finally:
if file: file.close()
raise ImportError, "Unrecognized module type (%s) for %s" % \ raise ImportError, "Unrecognized module type (%s) for %s" % \
(`type`, name) (`type`, name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment