Commit 37b4ce75 authored by Stefan Behnel's avatar Stefan Behnel

explicitly reject unknown compiler options to make cythonize() less unfriendly to use

parent 1165671b
......@@ -479,7 +479,7 @@ class CompilationOptions(object):
cplus boolean Compile as c++ code
"""
def __init__(self, defaults = None, **kw):
def __init__(self, defaults=None, **kw):
self.include_path = []
if defaults:
if isinstance(defaults, CompilationOptions):
......@@ -490,6 +490,16 @@ class CompilationOptions(object):
options = dict(defaults)
options.update(kw)
# let's assume 'default_options' contains a value for most known compiler options
# and validate against them
unknown_options = set(options) - set(default_options)
# 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" % (
's' if len(unknown_options) > 1 else '',
', '.join(unknown_options)))
directives = dict(options['compiler_directives']) # copy mutable field
options['compiler_directives'] = directives
if 'language_level' in directives and 'language_level' not in kw:
......@@ -675,4 +685,6 @@ default_options = dict(
gdb_debug = False,
compile_time_env = None,
common_utility_include_dir = None,
output_dir=None,
build_dir=None,
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment