diff options
author | Robert Bradshaw <robertwb@gmail.com> | 2014-10-13 16:26:47 -0700 |
---|---|---|
committer | Robert Bradshaw <robertwb@gmail.com> | 2014-10-13 16:26:47 -0700 |
commit | 60676a6c7644138596e902549c27ededa84d060f (patch) | |
tree | 8a36ee89909fc8ca0c7eebadf81625f588a4c171 /Cython/Compiler/Main.py | |
parent | aec028fd542b581f1ae9df42cb703adb444711c8 (diff) | |
parent | c52c6a6edf8b37fba7451bde77052ded64ddaf35 (diff) | |
download | cython-60676a6c7644138596e902549c27ededa84d060f.tar.gz |
Merge branch 'master' into grammar
Diffstat (limited to 'Cython/Compiler/Main.py')
-rw-r--r-- | Cython/Compiler/Main.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index ab2c48f27..7c2849305 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -7,7 +7,7 @@ from __future__ import absolute_import import os import re import sys -import codecs +import io if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[:2] < (3, 2): sys.stderr.write("Sorry, Cython requires Python 2.6+ or 3.2+, found %d.%d\n" % tuple(sys.version_info[:2])) @@ -22,10 +22,12 @@ from . import Errors from .Scanning import PyrexScanner, FileSourceDescriptor from .Errors import PyrexError, CompileError, error, warning from .Symtab import ModuleScope -from .. import __version__ as version from .. import Utils from . import Options +from . import Version # legacy import needed by old PyTables versions +version = Version.version # legacy attribute - use "Cython.__version__" instead + module_name_pattern = re.compile(r"[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$") verbose = 0 @@ -364,10 +366,9 @@ class Context(object): return ".".join(names) def setup_errors(self, options, result): - Errors.reset() # clear any remaining error state + Errors.reset() # clear any remaining error state if options.use_listing_file: - result.listing_file = Utils.replace_suffix(source, ".lis") - path = result.listing_file + path = result.listing_file = Utils.replace_suffix(result.main_source_file, ".lis") else: path = None Errors.open_listing_file(path=path, @@ -432,9 +433,10 @@ def run_pipeline(source, options, full_module_name=None, context=None): # By default, decide based on whether an html file already exists. html_filename = os.path.splitext(result.c_file)[0] + ".html" if os.path.exists(html_filename): - line = codecs.open(html_filename, "r", encoding="UTF-8").readline() - if line.startswith(u'<!-- Generated by Cython'): - options.annotate = True + with io.open(html_filename, "r", encoding="UTF-8") as html_file: + line = html_file.readline() + if line.startswith(u'<!-- Generated by Cython'): + options.annotate = True # Get pipeline if source_ext.lower() == '.py' or not source_ext: @@ -504,11 +506,14 @@ class CompilationOptions(object): # ignore valid options that are not in the defaults unknown_options.difference_update(['include_path']) if unknown_options: - raise ValueError("got unexpected compilation option%s: %s" % ( + # TODO: make this a hard error in 0.22 + message = "got unknown compilation option%s, please remove: %s" % ( 's' if len(unknown_options) > 1 else '', - ', '.join(unknown_options))) + ', '.join(unknown_options)) + import warnings + warnings.warn(message) - directives = dict(options['compiler_directives']) # copy mutable field + directives = dict(options['compiler_directives']) # copy mutable field options['compiler_directives'] = directives if 'language_level' in directives and 'language_level' not in kw: options['language_level'] = int(directives['language_level']) |