diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py
index 52427e31a0d85ac597cabd03e2ef5edfa6150304..6e313dd29883f2559609fb5836d837f406788696 100644
--- a/Cython/Compiler/Parsing.py
+++ b/Cython/Compiler/Parsing.py
@@ -2467,7 +2467,7 @@ def p_c_arg_decl(s, ctx, in_pyfunc, cmethod_flag = 0, nonempty = 0,
         annotation = p_test(s)
     if s.sy == '=':
         s.next()
-        if 'pxd' in s.level:
+        if 'pxd' in ctx.level:
             if s.sy not in ['*', '?']:
                 error(pos, "default values cannot be specified in pxd files, use ? or *")
             default = ExprNodes.BoolNode(1)