summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bradshaw <robertwb@gmail.com>2017-07-10 11:00:25 -0700
committerGitHub <noreply@github.com>2017-07-10 11:00:25 -0700
commitbbfaa7e367aa564ac475a3d9b46cc44104b6dfe6 (patch)
tree67a150a299b2e1bdf881c919b989ac5b8b91f76a
parent5ac65106bc1df31daf1f8c16e660f8cf92767ffb (diff)
parent0134568d0b5447b75d71ae8f69c207e559fa853c (diff)
downloadcython-bbfaa7e367aa564ac475a3d9b46cc44104b6dfe6.tar.gz
Merge pull request #1759 from jdemeyer/invalid_directives
Give an error for invalid options or directives
-rw-r--r--Cython/Compiler/Main.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py
index fb282b383..76cf93589 100644
--- a/Cython/Compiler/Main.py
+++ b/Cython/Compiler/Main.py
@@ -553,19 +553,24 @@ class CompilationOptions(object):
# ignore valid options that are not in the defaults
unknown_options.difference_update(['include_path'])
if unknown_options:
- # 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))
- import warnings
- warnings.warn(message)
+ raise ValueError(message)
directives = dict(options['compiler_directives']) # copy mutable field
+ # check for invalid directives
+ unknown_options = set(directives) - set(Options.get_directive_defaults())
+ if unknown_options:
+ message = "got unknown compiler directive%s: %s" % (
+ 's' if len(unknown_options) > 1 else '',
+ ', '.join(unknown_options))
+ raise ValueError(message)
+ options['compiler_directives'] = directives
if directives.get('np_pythran', False) and not options['cplus']:
import warnings
warnings.warn("C++ mode forced when in Pythran mode!")
options['cplus'] = True
- options['compiler_directives'] = directives
if 'language_level' in directives and 'language_level' not in kw:
options['language_level'] = int(directives['language_level'])
if 'formal_grammar' in directives and 'formal_grammar' not in kw: