[pypy-svn] r58758 - in pypy/branch/2.5-merge/pypy/objspace/std: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue Oct 7 16:17:05 CEST 2008
Author: cfbolz
Date: Tue Oct 7 16:17:02 2008
New Revision: 58758
Modified:
pypy/branch/2.5-merge/pypy/objspace/std/setobject.py
pypy/branch/2.5-merge/pypy/objspace/std/test/test_set.py
Log:
(iko, cfbolz): KeyErrors should have the key.
Modified: pypy/branch/2.5-merge/pypy/objspace/std/setobject.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/objspace/std/setobject.py (original)
+++ pypy/branch/2.5-merge/pypy/objspace/std/setobject.py Tue Oct 7 16:17:02 2008
@@ -444,23 +444,20 @@
try:
del w_left.setdata[w_f]
except KeyError:
- raise OperationError(space.w_KeyError,
- space.call_method(w_item,'__repr__'))
+ raise OperationError(space.w_KeyError, w_item)
def set_remove__Set_settypedef(space, w_left, w_item):
w_f = space.newfrozenset(make_setdata_from_w_iterable(space, w_item))
try:
del w_left.setdata[w_f]
except KeyError:
- raise OperationError(space.w_KeyError,
- space.call_method(w_item,'__repr__'))
+ raise OperationError(space.w_KeyError, w_item)
def set_remove__Set_ANY(space, w_left, w_item):
try:
del w_left.setdata[w_item]
except KeyError:
- raise OperationError(space.w_KeyError,
- space.call_method(w_item,'__repr__'))
+ raise OperationError(space.w_KeyError, w_item)
def hash__Frozenset(space, w_set):
multi = r_uint(1822399083) + r_uint(1822399083) + 1
Modified: pypy/branch/2.5-merge/pypy/objspace/std/test/test_set.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/objspace/std/test/test_set.py (original)
+++ pypy/branch/2.5-merge/pypy/objspace/std/test/test_set.py Tue Oct 7 16:17:02 2008
@@ -83,3 +83,11 @@
s.add(A(s))
assert repr(s) == "set([1, 2, 3, set(...)])"
+ def test_keyerror_has_key(self):
+ s = set()
+ try:
+ s.remove(1)
+ except KeyError, e:
+ assert e.args[0] == 1
+ else:
+ assert 0, "should raise"
More information about the Pypy-commit
mailing list