Don't use execfile() anymore

This commit is contained in:
Daniel Neuhäuser 2010-04-29 20:34:08 +02:00
parent 4adbc98350
commit 21376f21e7
2 changed files with 15 additions and 3 deletions

View File

@ -165,7 +165,11 @@ class Config(object):
try:
try:
os.chdir(dirname)
execfile(config['__file__'], config)
try:
f = open(config_file, 'U')
exec f in config
finally:
f.close()
except SyntaxError, err:
raise ConfigError('There is a syntax error in your '
'configuration file: ' + str(err))

View File

@ -85,7 +85,11 @@ def test_quickstart_defaults(tempdir):
conffile = tempdir / 'conf.py'
assert conffile.isfile()
ns = {}
execfile(conffile, ns)
try:
f = open(conffile, 'U')
exec f in ns
finally:
f.close()
assert ns['extensions'] == []
assert ns['templates_path'] == ['_templates']
assert ns['source_suffix'] == '.rst'
@ -138,7 +142,11 @@ def test_quickstart_all_answers(tempdir):
conffile = tempdir / 'source' / 'conf.py'
assert conffile.isfile()
ns = {}
execfile(conffile, ns)
try:
f = open(conffile, 'U')
exec f in ns
finally:
f.close()
assert ns['extensions'] == ['sphinx.ext.autodoc', 'sphinx.ext.doctest']
assert ns['templates_path'] == ['.templates']
assert ns['source_suffix'] == '.txt'