Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r88130:a3cce435fa17
Date: 2016-11-03 18:37 +0100
http://bitbucket.org/pypy/pypy/changeset/a3cce435fa17/
Log: reversed({})
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
@@ -328,6 +328,9 @@
if w_reversed_descr is not None:
w_reversed = space.get(w_reversed_descr, w_sequence)
return space.call_function(w_reversed)
+ if not space.issequence_w(w_sequence):
+ raise oefmt(space.w_TypeError,
+ "argument to reversed() must be a sequence")
self = space.allocate_instance(W_ReversedIterator, w_subtype)
self.__init__(space, w_sequence)
return space.wrap(self)
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
@@ -527,6 +527,9 @@
assert list(reversed(list(reversed("hello")))) == ['h','e','l','l','o']
raises(TypeError, reversed, reversed("hello"))
+ def test_reversed_nonsequence(self):
+ raises(TypeError, reversed, {})
+
def test_reversed_length_hint(self):
lst = [1, 2, 3]
r = reversed(lst)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit