summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Neuhäuser <ich@danielneuhaeuser.de>2010-04-29 20:34:08 +0200
committerDaniel Neuhäuser <ich@danielneuhaeuser.de>2010-04-29 20:34:08 +0200
commit21376f21e7cee76761fccef6874c88c1b3f79e3a (patch)
tree6e5254e322d672673998b65b132bfabec41dfb71
parent4adbc983503072918b058d6bfa6bca4fd64b86aa (diff)
downloadsphinx-git-21376f21e7cee76761fccef6874c88c1b3f79e3a.tar.gz
Don't use execfile() anymore
-rw-r--r--sphinx/config.py6
-rw-r--r--tests/test_quickstart.py12
2 files changed, 15 insertions, 3 deletions
diff --git a/sphinx/config.py b/sphinx/config.py
index 12c2a04ba..f76d330ac 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -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))
diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py
index cb40d27cf..34c54f95a 100644
--- a/tests/test_quickstart.py
+++ b/tests/test_quickstart.py
@@ -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'