[pypy-commit] pypy py3.5: python-dev confirmed the strange repr for recursive deques

arigo pypy.commits at gmail.com
Tue Dec 6 06:37:39 EST 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r88897:d96e6fa3d3ef
Date: 2016-12-06 12:37 +0100
http://bitbucket.org/pypy/pypy/changeset/d96e6fa3d3ef/

Log:	python-dev confirmed the strange repr for recursive deques

diff --git a/pypy/module/_collections/interp_deque.py b/pypy/module/_collections/interp_deque.py
--- a/pypy/module/_collections/interp_deque.py
+++ b/pypy/module/_collections/interp_deque.py
@@ -525,7 +525,9 @@
         'The app-level part of repr().'
         deque_id = id(d)
         if deque_id in currently_in_repr:
-            listrepr = '[...]'
+            return '[...]'   # strange because it's a deque and this
+                             # strongly suggests it's a list instead,
+                             # but confirmed behavior from python-dev
         else:
             currently_in_repr[deque_id] = 1
             try:
diff --git a/pypy/module/_collections/test/test_deque.py b/pypy/module/_collections/test/test_deque.py
--- a/pypy/module/_collections/test/test_deque.py
+++ b/pypy/module/_collections/test/test_deque.py
@@ -243,8 +243,9 @@
         d = deque(range(20))
         e = eval(repr(d))
         assert d == e
+        d = deque()
         d.append(d)
-        assert '...' in repr(d)
+        assert repr(d) == "deque([[...]])"
 
     def test_hash(self):
         from _collections import deque


More information about the pypy-commit mailing list