From a80790deb3677ebaf7f44a0e907eb9c420c4ef55 Mon Sep 17 00:00:00 2001 From: Craig Citro Date: Sun, 14 Mar 2010 21:40:49 -0700 Subject: [PATCH] Make multiple '--directive's on command line cumulative --- Cython/Compiler/CmdLine.py | 4 +++- Cython/Compiler/Options.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/CmdLine.py b/Cython/Compiler/CmdLine.py index 66cdc648..11feaa87 100644 --- a/Cython/Compiler/CmdLine.py +++ b/Cython/Compiler/CmdLine.py @@ -116,7 +116,9 @@ def parse_command_line(args): options.emit_linenums = True elif option in ("-X", "--directive"): try: - options.compiler_directives = Options.parse_directive_list(pop_arg(), relaxed_bool=True) + options.compiler_directives = Options.parse_directive_list( + pop_arg(), relaxed_bool=True, + current_settings=options.compiler_directives) except ValueError, e: sys.stderr.write("Error in compiler directive: %s\n" % e.args[0]) sys.exit(1) diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py index 270e19ff..5f32abdd 100644 --- a/Cython/Compiler/Options.py +++ b/Cython/Compiler/Options.py @@ -129,7 +129,8 @@ def parse_directive_value(name, value, relaxed_bool=False): else: assert False -def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False): +def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False, + current_settings=None): """ Parses a comma-separated list of pragma options. Whitespace is not considered. @@ -152,7 +153,10 @@ def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False): ... ValueError: Unknown option: "unknown" """ - result = {} + if current_settings is None: + result = {} + else: + result = current_settings for item in s.split(','): item = item.strip() if not item: continue -- 2.26.2