support Ellipsis as compile time constant
authorStefan Behnel <stefan_ml@behnel.de>
Sat, 23 Feb 2013 09:55:55 +0000 (10:55 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Sat, 23 Feb 2013 09:55:55 +0000 (10:55 +0100)
Cython/Compiler/Parsing.py
tests/run/ct_DEF.pyx

index 779c3b4..6d486db 100644 (file)
@@ -693,6 +693,8 @@ def wrap_compile_time_constant(pos, value):
     rep = repr(value)
     if value is None:
         return ExprNodes.NoneNode(pos)
+    elif value is Ellipsis:
+        return ExprNodes.EllipsisNode(pos)
     elif isinstance(value, bool):
         return ExprNodes.BoolNode(pos, value=value)
     elif isinstance(value, int):
index 3ca0298..29a82c2 100644 (file)
@@ -29,8 +29,10 @@ DEF TRUE  = TRUE_FALSE[0]
 DEF FALSE = TRUE_FALSE[1]
 DEF INT_TUPLE1 = TUPLE[:2]
 DEF INT_TUPLE2 = TUPLE[1:4:2]
+DEF ELLIPSIS = ...
 DEF EXPRESSION = int(float(2*2)) + int(str(2)) + int(max(1,2,3)) + sum([TWO, FIVE])
 
+
 def c():
     """
     >>> c()
@@ -148,6 +150,13 @@ def false():
     cdef bint false = FALSE
     return false
 
+def ellipsis():
+    """
+    >>> ellipsis()
+    Ellipsis
+    """
+    return ELLIPSIS
+
 @cython.test_assert_path_exists('//IntNode')
 @cython.test_fail_if_path_exists('//AddNode')
 def expression():