[pypy-svn] pypy default: Wrong. A test was present but failed on CPython 2.7 (with -A).
arigo
commits-noreply at bitbucket.org
Sun May 8 13:00:25 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r43944:9ccaeaff6e07
Date: 2011-05-08 13:00 +0200
http://bitbucket.org/pypy/pypy/changeset/9ccaeaff6e07/
Log: Wrong. A test was present but failed on CPython 2.7 (with -A).
Killed it, and replaced it with tests that check that even when
making new frozen sets, the overridden __new__ is not called.
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
@@ -59,10 +59,9 @@
if type(w_self) is W_FrozensetObject:
return W_FrozensetObject(space, rdict_w)
w_type = space.type(w_self)
- _, w_newdescr = w_type.lookup_where('__new__')
- w_newfunc = space.get(w_newdescr, w_type)
- w_itemiterator = W_SetIterObject(rdict_w)
- return space.call_function(w_newfunc, w_type, w_itemiterator)
+ w_obj = space.allocate_instance(W_FrozensetObject, w_type)
+ W_FrozensetObject.__init__(w_obj, space, rdict_w)
+ return w_obj
registerimplementation(W_BaseSetObject)
registerimplementation(W_SetObject)
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
@@ -69,10 +69,19 @@
assert s == frozenset('abc') # the __init__ is ignored
def test_subtype_bug(self):
- class subset(set):pass
- b = subset('abc').copy()
+ class subset(set): pass
+ b = subset('abc')
+ subset.__new__ = lambda *args: foobar # not called
+ b = b.copy()
assert type(b) is subset
assert set(b) == set('abc')
+ #
+ class frozensubset(frozenset): pass
+ b = frozensubset('abc')
+ frozensubset.__new__ = lambda *args: foobar # not called
+ b = b.copy()
+ assert type(b) is frozensubset
+ assert frozenset(b) == frozenset('abc')
def test_union(self):
a = set([4, 5])
@@ -148,11 +157,6 @@
assert s1 is not s2
assert s1 == s2
assert type(s2) is myfrozen
- class myfrozen(frozenset):
- def __new__(cls):
- return frozenset.__new__(cls, 'abc')
- s1 = myfrozen()
- raises(TypeError, s1.copy)
def test_update(self):
s1 = set('abc')
More information about the Pypy-commit
mailing list