summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2012-08-15 01:21:40 -0700
committerAlex Gaynor <alex.gaynor@rd.io>2012-08-15 01:21:40 -0700
commit20a7a244d78b835473c3e4d9b86e1c991d252daf (patch)
tree385fc8ab03cf48b55fe1dc7d8731fd39cc6cf960
parentc7734491f87ac711ff5d749213e8cac0adb3686b (diff)
Make sure to explicitly close opened files.
-rw-r--r--django/core/management/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index 268cd63c38..adf34971f9 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -51,14 +51,19 @@ def find_management_module(app_name):
# module, we need look for the case where the project name is part
# of the app_name but the project directory itself isn't on the path.
try:
- f, path, descr = imp.find_module(part,path)
+ f, path, descr = imp.find_module(part, path)
except ImportError as e:
if os.path.basename(os.getcwd()) != part:
raise e
+ finally:
+ if f:
+ f.close()
while parts:
part = parts.pop()
f, path, descr = imp.find_module(part, path and [path] or None)
+ if f:
+ f.close()
return path
def load_command_class(app_name, name):