From 4282e6d2c172ae451db4ec0de07cfb05fe5ae7a1 Mon Sep 17 00:00:00 2001 From: Craig Citro Date: Thu, 7 Jan 2010 10:59:59 -0800 Subject: [PATCH] Fix parsing for allowing def statements only where legal. --- Cython/Compiler/Parsing.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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': -- 2.26.2