Commit 327311c0 authored by Stefan Behnel's avatar Stefan Behnel

support None as compile time constant expression

parent 108982d7
......@@ -691,7 +691,9 @@ def p_name(s, name):
def wrap_compile_time_constant(pos, value):
rep = repr(value)
if isinstance(value, bool):
if value is None:
return ExprNodes.NoneNode(pos)
elif isinstance(value, bool):
return ExprNodes.BoolNode(pos, value=value)
elif isinstance(value, int):
return ExprNodes.IntNode(pos, value=rep)
......
......@@ -8,6 +8,5 @@ x = t_non_const
_ERRORS = u"""
5:32: Error in compile-time expression: IndexError: tuple index out of range
7:15: Invalid type for compile-time constant: None (type NoneType)
7:15: Invalid type for compile-time constant: [1, 2, 3] (type list)
"""
......@@ -13,6 +13,7 @@ if sys.version_info[0] < 3:
DEF TUPLE = (1, 2, u"buckle my shoe")
DEF TRUE_FALSE = (True, False)
DEF NONE = None
DEF CHAR = c'x'
DEF INT0 = -1
......@@ -156,3 +157,9 @@ def expression():
"""
cdef int i = EXPRESSION
return i
def none():
"""
>>> none()
"""
return NONE
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment