mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use code objects for exec statements instead of files
This commit is contained in:
parent
b81d428b89
commit
25b16f89e0
@ -167,9 +167,10 @@ class Config(object):
|
||||
os.chdir(dirname)
|
||||
f = open(config_file, 'U')
|
||||
try:
|
||||
exec f in config
|
||||
code = compile(f.read(), config_file, 'exec')
|
||||
finally:
|
||||
f.close()
|
||||
exec code in config
|
||||
except SyntaxError, err:
|
||||
raise ConfigError('There is a syntax error in your '
|
||||
'configuration file: ' + str(err))
|
||||
|
@ -87,9 +87,10 @@ def test_quickstart_defaults(tempdir):
|
||||
ns = {}
|
||||
f = open(conffile, 'U')
|
||||
try:
|
||||
exec f in ns
|
||||
code = compile(f.read(), conffile, 'exec')
|
||||
finally:
|
||||
f.close()
|
||||
exec code in ns
|
||||
assert ns['extensions'] == []
|
||||
assert ns['templates_path'] == ['_templates']
|
||||
assert ns['source_suffix'] == '.rst'
|
||||
@ -144,9 +145,10 @@ def test_quickstart_all_answers(tempdir):
|
||||
ns = {}
|
||||
f = open(conffile, 'U')
|
||||
try:
|
||||
exec f in ns
|
||||
code = compile(f.read(), conffile, 'exec')
|
||||
finally:
|
||||
f.close()
|
||||
exec code in ns
|
||||
assert ns['extensions'] == ['sphinx.ext.autodoc', 'sphinx.ext.doctest']
|
||||
assert ns['templates_path'] == ['.templates']
|
||||
assert ns['source_suffix'] == '.txt'
|
||||
|
Loading…
Reference in New Issue
Block a user