Fix config.from_pyfile on Python 3 (#2123)

* Fix config.from_pyfile on Python 3

Fix #2118

* Support Python 2.6

* Fix tests on Python 2
This commit is contained in:
Markus Unterwaditzer 2016-12-26 03:50:47 +01:00 committed by GitHub
parent 8cd0b03bee
commit 789715adb9
3 changed files with 24 additions and 3 deletions

View file

@ -126,7 +126,7 @@ class Config(dict):
d = types.ModuleType('config')
d.__file__ = filename
try:
with open(filename) as config_file:
with open(filename, mode='rb') 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):