[pypy-svn] r69276 - in pypy/branch/faster-raise/pypy/module/exceptions: . test

fijal at codespeak.net fijal at codespeak.net
Sat Nov 14 13:15:55 CET 2009


Author: fijal
Date: Sat Nov 14 13:15:54 2009
New Revision: 69276

Modified:
   pypy/branch/faster-raise/pypy/module/exceptions/interp_exceptions.py
   pypy/branch/faster-raise/pypy/module/exceptions/test/test_exc.py
Log:
(arigo, fijal) Support getitem


Modified: pypy/branch/faster-raise/pypy/module/exceptions/interp_exceptions.py
==============================================================================
--- pypy/branch/faster-raise/pypy/module/exceptions/interp_exceptions.py	(original)
+++ pypy/branch/faster-raise/pypy/module/exceptions/interp_exceptions.py	Sat Nov 14 13:15:54 2009
@@ -132,6 +132,10 @@
     def descr_setargs(space, self, w_newargs):
         self.args_w = space.viewiterable(w_newargs)
 
+    def descr_getitem(self, space, w_index):
+        return space.getitem(space.newtuple(self.args_w), w_index)
+    descr_getitem.unwrap_spec = ['self', ObjSpace, W_Root]
+
     def getdict(self):
         if self.w_dict is None:
             self.w_dict = self.space.newdict()
@@ -174,6 +178,7 @@
     __repr__ = interp2app(W_BaseException.descr_repr),
     __dict__ = GetSetProperty(descr_get_dict, descr_set_dict,
                               cls=W_BaseException),
+    __getitem__ = interp2app(W_BaseException.descr_getitem),
     __reduce__ = interp2app(W_BaseException.descr_reduce),
     __setstate__ = interp2app(W_BaseException.descr_setstate),
     message = interp_attrproperty_w('w_message', W_BaseException),

Modified: pypy/branch/faster-raise/pypy/module/exceptions/test/test_exc.py
==============================================================================
--- pypy/branch/faster-raise/pypy/module/exceptions/test/test_exc.py	(original)
+++ pypy/branch/faster-raise/pypy/module/exceptions/test/test_exc.py	Sat Nov 14 13:15:54 2009
@@ -25,6 +25,9 @@
         assert x.xyz == 3
         x.args = [42]
         assert x.args == (42,)
+        assert x[0] == 42
+        x.args = (1, 2, 3)
+        assert x[1:2] == (2,)
 
     def test_exc(self):
         from exceptions import Exception, BaseException



More information about the Pypy-commit mailing list