]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Use with statement for opening file
authorHong Minhee <minhee@dahlia.kr>
Fri, 12 Apr 2013 19:41:32 +0000 (04:41 +0900)
committerHong Minhee <minhee@dahlia.kr>
Fri, 12 Apr 2013 19:41:32 +0000 (04:41 +0900)
alembic/util.py

index e16707d209789cc93d5a17c5848222fb004fd8e4..6111d20203b7b32ba3d97747d9f06b6a5f6481fe 100644 (file)
@@ -185,7 +185,8 @@ def load_python_file(dir_, filename):
 
     module_id = re.sub(r'\W', "_", filename)
     path = os.path.join(dir_, filename)
-    module = imp.load_source(module_id, path, open(path, 'rb'))
+    with open(path, 'r') as f:
+        module = imp.load_source(module_id, path, f)
     del sys.modules[module_id]
     return module