From: Craig Citro Date: Thu, 7 Jan 2010 18:59:59 +0000 (-0800) Subject: Fix parsing for allowing def statements only where legal. X-Git-Tag: 0.13.beta0~2^2~104^2~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4282e6d2c172ae451db4ec0de07cfb05fe5ae7a1;p=cython.git Fix parsing for allowing def statements only where legal. --- diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index ec346a23..6db439c9 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -1658,8 +1658,10 @@ def p_statement(s, ctx, first_statement = 0): if ctx.api: error(s.pos, "'api' not allowed with this statement") elif s.sy == 'def': - #if ctx.level not in ('module', 'class', 'c_class', 'c_class_pxd', 'property', 'function'): - # s.error('def statement not allowed here') + # def statements aren't allowed in pxd files, except + # as part of a cdef class + if ('pxd' in ctx.level) and (ctx.level != 'c_class_pxd'): + s.error('def statement not allowed here') s.level = ctx.level return p_def_statement(s, decorators) elif s.sy == 'class':