diff options
author | shimizukawa <shimizukawa@gmail.com> | 2013-02-10 15:25:45 +0900 |
---|---|---|
committer | shimizukawa <shimizukawa@gmail.com> | 2013-02-10 15:25:45 +0900 |
commit | a24ce1a4bb568c7d23879cfc46677cc105b553f6 (patch) | |
tree | 0cddde06dd0410a72f5ed7ae3da6d52dfbc403b6 /sphinx/config.py | |
parent | da7ae91eaeeab430993f9e9dc20d93d5d4ed3975 (diff) | |
download | sphinx-a24ce1a4bb568c7d23879cfc46677cc105b553f6.tar.gz |
conf.py now accept CRLF end-of-line.
Diffstat (limited to 'sphinx/config.py')
-rw-r--r-- | sphinx/config.py | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/sphinx/config.py b/sphinx/config.py index 0374df97..36a5b862 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -16,8 +16,8 @@ from os import path from sphinx.errors import ConfigError from sphinx.locale import l_ -from sphinx.util.osutil import make_filename, fs_encoding -from sphinx.util.pycompat import bytes, b, convert_with_2to3 +from sphinx.util.osutil import make_filename +from sphinx.util.pycompat import bytes, b, execfile_ nonascii_re = re.compile(b(r'[\x80-\xff]')) @@ -219,27 +219,8 @@ 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 -- '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(filename, 'rbU') try: - source = f.read() - finally: - f.close() - try: - # compile to a code object, handle syntax errors - config_file_enc = config_file.encode(fs_encoding) - try: - code = compile(source, config_file_enc, 'exec') - except SyntaxError: - if convert_with_2to3: - # maybe the file uses 2.x syntax; try to refactor to - # 3.x syntax using 2to3 - source = convert_with_2to3(config_file) - code = compile(source, config_file_enc, 'exec') - else: - raise - exec code in config + execfile_(filename, config) except SyntaxError, err: raise ConfigError(CONFIG_SYNTAX_ERROR % err) finally: |