From 43b6d0a6d062ace75cc2b0f7200b770eac23edcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Neuha=CC=88user?= Date: Wed, 22 May 2013 22:49:25 +0200 Subject: [PATCH] Ensure that config file is closed immediately --- flask/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flask/config.py b/flask/config.py index ddb113a5..4d9ac23a 100644 --- a/flask/config.py +++ b/flask/config.py @@ -125,7 +125,8 @@ class Config(dict): d = imp.new_module('config') d.__file__ = filename try: - exec(compile(open(filename).read(), filename, 'exec'), d.__dict__) + with open(filename) as config_file: + exec(compile(config_file.read(), filename, 'exec'), d.__dict__) except IOError as e: if silent and e.errno in (errno.ENOENT, errno.EISDIR): return False