Author: Hakan Ardo <[email protected]>
Branch:
Changeset: r48767:aa07c2a53f95
Date: 2011-11-04 22:37 +0100
http://bitbucket.org/pypy/pypy/changeset/aa07c2a53f95/
Log: hg backout 7202b0d9cb70
diff --git a/pypy/module/__builtin__/functional.py
b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -362,7 +362,7 @@
def descr_reversed(self):
lastitem = self.start + (self.len-1) * self.step
return self.space.wrap(W_XRangeIterator(self.space, lastitem,
- self.start, -self.step, True))
+ self.start - 1, -self.step))
def descr_reduce(self):
space = self.space
@@ -389,26 +389,21 @@
)
class W_XRangeIterator(Wrappable):
- def __init__(self, space, start, stop, step, inclusive=False):
+ def __init__(self, space, start, stop, step):
self.space = space
self.current = start
self.stop = stop
self.step = step
- self.inclusive = inclusive
def descr_iter(self):
return self.space.wrap(self)
def descr_next(self):
- if self.inclusive:
- if not ((self.step > 0 and self.current <= self.stop) or
(self.step < 0 and self.current >= self.stop)):
- raise OperationError(self.space.w_StopIteration,
self.space.w_None)
- else:
- if not ((self.step > 0 and self.current < self.stop) or (self.step
< 0 and self.current > self.stop)):
- raise OperationError(self.space.w_StopIteration,
self.space.w_None)
- item = self.current
- self.current = item + self.step
- return self.space.wrap(item)
+ if (self.step > 0 and self.current < self.stop) or (self.step < 0 and
self.current > self.stop):
+ item = self.current
+ self.current = item + self.step
+ return self.space.wrap(item)
+ raise OperationError(self.space.w_StopIteration, self.space.w_None)
#def descr_len(self):
# return self.space.wrap(self.remaining)
diff --git a/pypy/module/__builtin__/test/test_functional.py
b/pypy/module/__builtin__/test/test_functional.py
--- a/pypy/module/__builtin__/test/test_functional.py
+++ b/pypy/module/__builtin__/test/test_functional.py
@@ -157,8 +157,7 @@
raises(OverflowError, xrange, a)
raises(OverflowError, xrange, 0, a)
raises(OverflowError, xrange, 0, 1, a)
- assert list(reversed(xrange(-sys.maxint-1, -sys.maxint-1, -2))) == []
-
+
def test_xrange_reduce(self):
x = xrange(2, 9, 3)
callable, args = x.__reduce__()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit