Commit b0890818 authored by Stefan Behnel's avatar Stefan Behnel

fixes for compile-time slicing

parent 3fe3c573
......@@ -1754,8 +1754,14 @@ class SliceIndexNode(ExprNode):
def compile_time_value(self, denv):
base = self.base.compile_time_value(denv)
start = self.start.compile_time_value(denv)
stop = self.stop.compile_time_value(denv)
if self.start is None:
start = 0
else:
start = self.start.compile_time_value(denv)
if self.stop is None:
stop = None
else:
stop = self.stop.compile_time_value(denv)
try:
return base[start:stop]
except Exception, e:
......@@ -1837,8 +1843,14 @@ class SliceNode(ExprNode):
def compile_time_value(self, denv):
start = self.start.compile_time_value(denv)
stop = self.stop.compile_time_value(denv)
step = step.step.compile_time_value(denv)
if self.stop is None:
stop = None
else:
stop = self.stop.compile_time_value(denv)
if self.step is None:
step = None
else:
step = self.step.compile_time_value(denv)
try:
return slice(start, stop, step)
except Exception, e:
......
......@@ -51,6 +51,8 @@ DEF TWO = TUPLE[1]
DEF FIVE = TWO + 3
DEF TRUE = TRUE_FALSE[0]
DEF FALSE = TRUE_FALSE[1]
DEF INT_TUPLE1 = TUPLE[:2]
DEF INT_TUPLE2 = TUPLE[1:4:2]
def c():
cdef char c
......@@ -108,6 +110,12 @@ def two():
two = TWO
return two
# this doesn't currently work!
#def two2():
# cdef int two
# two = INT_TUPLE1[-1]
# return two
def five():
cdef int five
five = FIVE
......
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