Fixes #875 and #876: use the right file mode to successfully read config files under 2.x and 3.x.

This commit is contained in:
Georg Brandl 2012-03-10 18:45:14 +01:00
parent 219905a3be
commit 75ec8f27d5
2 changed files with 5 additions and 4 deletions

View File

@ -194,8 +194,9 @@ class Config(object):
# we promise to have the config dir as current dir while the
# config file is executed
os.chdir(dirname)
# get config source
f = open(config_file, 'rU')
# get config source -- 'b' is a no-op under 2.x, while 'U' is
# ignored under 3.x (but 3.x compile() accepts \r\n newlines)
f = open(config_file, 'rbU')
try:
source = f.read()
finally:

View File

@ -91,7 +91,7 @@ def test_quickstart_defaults(tempdir):
conffile = tempdir / 'conf.py'
assert conffile.isfile()
ns = {}
f = open(conffile, 'U')
f = open(conffile, 'rbU')
try:
code = compile(f.read(), conffile, 'exec')
finally:
@ -151,7 +151,7 @@ def test_quickstart_all_answers(tempdir):
conffile = tempdir / 'source' / 'conf.py'
assert conffile.isfile()
ns = {}
f = open(conffile, 'U')
f = open(conffile, 'rbU')
try:
code = compile(f.read(), conffile, 'exec')
finally: