[pypy-commit] pypy py3k: we need to put the chek for the empty set inside the try/finally, else the id() is never removed from currently_in_repr
antocuni
noreply at buildbot.pypy.org
Tue Sep 25 17:15:25 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r57583:125172469521
Date: 2012-09-25 12:16 +0200
http://bitbucket.org/pypy/pypy/changeset/125172469521/
Log: we need to put the chek for the empty set inside the try/finally,
else the id() is never removed from currently_in_repr
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -1393,9 +1393,9 @@
if set_id in currently_in_repr:
return '%s(...)' % (s.__class__.__name__,)
currently_in_repr[set_id] = 1
- if not s:
- return '%s()' % (s.__class__.__name__,)
try:
+ if not s:
+ return '%s()' % (s.__class__.__name__,)
listrepr = repr([x for x in s])
if type(s) is set:
return '{%s}' % (listrepr[1:-1],)
diff --git a/pypy/objspace/std/test/test_setobject.py b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -55,7 +55,9 @@
def test_space_newset(self):
s = self.space.newset()
assert self.space.str_w(self.space.repr(s)) == 'set()'
-
+ # check that the second time we don't get 'set(...)'
+ assert self.space.str_w(self.space.repr(s)) == 'set()'
+
def test_intersection_order(self):
# theses tests make sure that intersection is done in the correct order
# (smallest first)
More information about the pypy-commit
mailing list