Change command-line directive behaviour for 0.12
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 16 Oct 2009 08:30:31 +0000 (10:30 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 16 Oct 2009 08:30:31 +0000 (10:30 +0200)
Cython/Compiler/CmdLine.py
Cython/Compiler/ParseTreeTransforms.py

index 67b3737b5d8b78f4919a7398340bf4bb91f49ee6..3451e734ebb7bf0a76b690e04cfc76f1cfde84c7 100644 (file)
@@ -39,12 +39,12 @@ Options:
   --line-directives              Produce #line directives pointing to the .pyx source
   --cplus                        Output a c++ rather than c file.
   --embed                        Embed the Python interpreter in a main() method.
-  --directive <name>=<value>[,<name=value,...] Overrides a compiler directive
+  -X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive
 """
 
 #The following experimental options are supported only on MacOSX:
 #  -C, --compile    Compile generated .c file to .o file
-#  -X, --link       Link .o file to produce extension module (implies -C)
+#  --link           Link .o file to produce extension module (implies -C)
 #  -+, --cplus      Use C++ compiler for compiling and linking
 #  Additional .o files to link may be supplied when using -X."""
 
@@ -81,11 +81,7 @@ def parse_command_line(args):
                 options.use_listing_file = 1
             elif option in ("-C", "--compile"):
                 options.c_only = 0
-            elif option in ("-X", "--link"):
-                if option == "-X":
-                    print >>sys.stderr, "Deprecation warning: The -X command line switch will be changed to a"
-                    print >>sys.stderr, "shorthand for --directive in Cython 0.12. Please use --link instead."
-                    print >>sys.stderr
+            elif option in ("--link"):
                 options.c_only = 0
                 options.obj_only = 0
             elif option in ("-+", "--cplus"):
index a1eb2e5f4b9f85160dba5b74468bafe3be9fff60..00b47bc74cc3da82daed9ad6f3897d6a69f5fb4d 100644 (file)
@@ -330,11 +330,11 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
     """
     special_methods = set(['declare', 'union', 'struct', 'typedef', 'sizeof', 'typeof', 'cast', 'address', 'pointer', 'compiled', 'NULL'])
 
-    def __init__(self, context, compilation_directive_overrides):
+    def __init__(self, context, compilation_directive_defaults):
         super(InterpretCompilerDirectives, self).__init__(context)
-        self.compilation_directive_overrides = {}
-        for key, value in compilation_directive_overrides.iteritems():
-            self.compilation_directive_overrides[unicode(key)] = value
+        self.compilation_directive_defaults = {}
+        for key, value in compilation_directive_defaults.iteritems():
+            self.compilation_directive_defaults[unicode(key)] = value
         self.cython_module_names = set()
         self.directive_names = {}
 
@@ -349,17 +349,14 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
         
     # Set up processing and handle the cython: comments.
     def visit_ModuleNode(self, node):
-        directives = copy.copy(Options.directive_defaults)
-        for key, value in self.compilation_directive_overrides.iteritems():
+        for key, value in node.directive_comments.iteritems():
             if not self.check_directive_scope(node.pos, key, 'module'):
                 self.wrong_scope_error(node.pos, key, 'module')
-                del self.compilation_directive_overrides[key]
-                continue
-            if key in node.directive_comments and node.directive_comments[key] != value:
-                warning(node.pos, "Compiler directive differs between environment and file header; this will change "
-                        "in Cython 0.12. See http://article.gmane.org/gmane.comp.python.cython.devel/5233", 2)
+                del node.directive_comments[key]
+
+        directives = copy.copy(Options.directive_defaults)
+        directives.update(self.compilation_directive_defaults)
         directives.update(node.directive_comments)
-        directives.update(self.compilation_directive_overrides)
         self.directives = directives
         node.directives = directives
         self.visitchildren(node)