diff options
Diffstat (limited to 'Cython/Compiler/Parsing.py')
-rw-r--r-- | Cython/Compiler/Parsing.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 94fc2eca1..3fc6c3f26 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -746,7 +746,7 @@ def p_atom_string(s): s.error("invalid string kind '%s'" % kind) -def p_atom_ident_constants(s): +def p_atom_ident_constants(s, bools_are_pybool=False): """ Returns None if it isn't one special-cased named constants. Only calls s.next() if it successfully matches a matches. @@ -754,12 +754,16 @@ def p_atom_ident_constants(s): pos = s.position() name = s.systring result = None + if bools_are_pybool: + extra_kwds = {'type': Builtin.bool_type} + else: + extra_kwds = {} if name == "None": result = ExprNodes.NoneNode(pos) elif name == "True": - result = ExprNodes.BoolNode(pos, value=True) + result = ExprNodes.BoolNode(pos, value=True, **extra_kwds) elif name == "False": - result = ExprNodes.BoolNode(pos, value=False) + result = ExprNodes.BoolNode(pos, value=False, **extra_kwds) elif name == "NULL" and not s.in_python_file: result = ExprNodes.NullNode(pos) if result: @@ -4286,7 +4290,7 @@ def p_literal_pattern(s): elif sy == 'IDENT': # Note that p_atom_ident_constants includes NULL. # This is a deliberate Cython addition to the pattern matching specification - result = p_atom_ident_constants(s) + result = p_atom_ident_constants(s, bools_are_pybool=True) if result: return MatchCaseNodes.MatchValuePatternNode(pos, value=result, is_is_check=True) |