ticket #128: disable Cython type declarations in signatures of .py files
authorStefan Behnel <scoder@users.berlios.de>
Sun, 14 Mar 2010 13:48:18 +0000 (14:48 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 14 Mar 2010 13:48:18 +0000 (14:48 +0100)
Cython/Compiler/Parsing.py
Cython/Compiler/Scanning.pxd
Cython/Compiler/Scanning.py

index 8abd96b6709c207d60bdbef4158dea38224ba935..3ee56367c639fd7c6283607346d34ce45fff03c4 100644 (file)
@@ -2089,9 +2089,17 @@ def p_c_arg_decl(s, ctx, in_pyfunc, cmethod_flag = 0, nonempty = 0, kw_only = 0)
     pos = s.position()
     not_none = 0
     default = None
-    base_type = p_c_base_type(s, cmethod_flag, nonempty = nonempty)
+    if s.in_python_file:
+        # empty type declaration
+        base_type = Nodes.CSimpleBaseTypeNode(pos,
+            name = None, module_path = [],
+            is_basic_c_type = 0, signed = 0,
+            complex = 0, longness = 0,
+            is_self_arg = cmethod_flag, templates = None)
+    else:
+        base_type = p_c_base_type(s, cmethod_flag, nonempty = nonempty)
     declarator = p_c_declarator(s, ctx, nonempty = nonempty)
-    if s.sy == 'not':
+    if s.sy == 'not' and not s.in_python_file:
         s.next()
         if s.sy == 'IDENT' and s.systring == 'None':
             s.next()
index d98b71328eca9255671d3e9be0187be22e0ba2ab..abcc5eeaa04ff7f5467fc45c1e43ff8c2c15a88d 100644 (file)
@@ -13,6 +13,7 @@ cdef class PyrexScanner(Scanner):
     cdef public bint compile_time_eval
     cdef public bint compile_time_expr
     cdef public bint parse_comments
+    cdef public bint in_python_file
     cdef public source_encoding
     cdef set keywords
     cdef public list indentation_stack
index bdbf46c48053e07425955506de759044458f4ac8..fc07a0d11a8337977edd5219c161b33a2586d5aa 100644 (file)
@@ -255,8 +255,10 @@ class PyrexScanner(Scanner):
         self.parse_comments = parse_comments
         self.source_encoding = source_encoding
         if filename.is_python_file():
+            self.in_python_file = True
             self.keywords = cython.set(py_reserved_words)
         else:
+            self.in_python_file = False
             self.keywords = cython.set(pyx_reserved_words)
         self.trace = trace_scanner
         self.indentation_stack = [0]