From: Hong Minhee Date: Fri, 12 Apr 2013 19:41:32 +0000 (+0900) Subject: Use with statement for opening file X-Git-Tag: rel_0_6_0~22^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c8ebfb744a1a1e39927635ac7a7fb39ec54f807;p=thirdparty%2Fsqlalchemy%2Falembic.git Use with statement for opening file --- diff --git a/alembic/util.py b/alembic/util.py index e16707d2..6111d202 100644 --- a/alembic/util.py +++ b/alembic/util.py @@ -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