1
0
mirror of https://github.com/django/django.git synced 2024-12-24 10:05:46 +00:00

Make sure to explicitly close opened files.

This commit is contained in:
Alex Gaynor 2012-08-15 01:21:40 -07:00 committed by Alex Gaynor
parent c7734491f8
commit 20a7a244d7

View File

@ -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):