From: Robert Bradshaw Date: Sat, 16 Aug 2008 22:07:42 +0000 (-0700) Subject: Require cython: for compiler directives X-Git-Tag: 0.9.8.1~12 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=eb1a531e9311d10d7670855da604f494fca453aa;p=cython.git Require cython: for compiler directives --- diff --git a/Cython/Compiler/CythonScope.py b/Cython/Compiler/CythonScope.py index 289d5743..d14d7c80 100644 --- a/Cython/Compiler/CythonScope.py +++ b/Cython/Compiler/CythonScope.py @@ -13,7 +13,7 @@ class CythonScope(ModuleScope): self.shape_entry = self.declare_cfunction('shape', shape_func_type, pos=None, - visibility='extern', + defining = 1, cname='') def create_cython_scope(context): diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 7a8cc029..9f5e0539 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -1272,6 +1272,7 @@ def p_include_statement(s, ctx): f = Utils.open_source_file(include_file_path, mode="rU") source_desc = FileSourceDescriptor(include_file_path) s2 = PyrexScanner(f, source_desc, s, source_encoding=f.encoding) + s2.parse_comments = s.parse_comments try: tree = p_statement_list(s2, ctx) finally: @@ -2346,7 +2347,7 @@ def p_code(s, level=None): repr(s.sy), repr(s.systring))) return body -COMPILER_DIRECTIVE_COMMENT_RE = re.compile(r"^#\s*([a-z]+)\s*=(.*)$") +COMPILER_DIRECTIVE_COMMENT_RE = re.compile(r"^#\s*cython:\s*([a-z]+)\s*=(.*)$") def p_compiler_directive_comments(s): result = {} diff --git a/tests/compile/c_directives.pyx b/tests/compile/c_directives.pyx index ccb22d08..f6158976 100644 --- a/tests/compile/c_directives.pyx +++ b/tests/compile/c_directives.pyx @@ -1,5 +1,5 @@ -# boundscheck = False -# ignoreme = OK +# cython: boundscheck = False +# cython: ignoreme = OK # This testcase is most useful if you inspect the generated C file @@ -17,7 +17,7 @@ def f(object[int, ndim=2] buf): @cy.boundscheck(True) def g(object[int, ndim=2] buf): # The below line should have no meaning -# boundscheck = False +# cython: boundscheck = False # even if the above line doesn't follow indentation. print buf[3, 2] # bc diff --git a/tests/errors/e_directives.pyx b/tests/errors/e_directives.pyx index c626b4fd..f63270fd 100644 --- a/tests/errors/e_directives.pyx +++ b/tests/errors/e_directives.pyx @@ -1,12 +1,12 @@ -# nonexistant = True -# boundscheck = true -# boundscheck = 9 +# cython: nonexistant = True +# cython: boundscheck = true +# cython: boundscheck = 9 print 3 # Options should not be interpreted any longer: -# boundscheck = true +# cython: boundscheck = true _ERRORS = u""" 3:0: boundscheck directive must be set to True or False