Rev 133: Comment about what we want __getitem__ to do when the object can't be found. in http://bazaar.launchpad.net/~jameinel/meliae/mem-object-collection
John Arbash Meinel
john at arbash-meinel.com
Mon Dec 28 04:40:54 GMT 2009
At http://bazaar.launchpad.net/~jameinel/meliae/mem-object-collection
------------------------------------------------------------
revno: 133
revision-id: john at arbash-meinel.com-20091228044038-bkwaqjf1p9feehvv
parent: john at arbash-meinel.com-20091228042527-or9tftzvy4g19q75
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: mem-object-collection
timestamp: Sun 2009-12-27 22:40:38 -0600
message:
Comment about what we want __getitem__ to do when the object can't be found.
-------------- next part --------------
=== modified file 'meliae/_loader.pyx'
--- a/meliae/_loader.pyx 2009-12-28 04:25:27 +0000
+++ b/meliae/_loader.pyx 2009-12-28 04:40:38 +0000
@@ -256,18 +256,13 @@
if off >= self._obj.ref_list.size:
raise IndexError('%s has only %d (not %d) references'
% (self, self._obj.ref_list.size, offset))
- return self.collection[<object>self._obj.ref_list.refs[off]]
-
- # def __getitem__(self, offset):
- # cdef _MemObject *slot
- # cdef PyObject *item_addr
- # cdef long off
-
- # slot = self._get_obj()
- # if slot.ref_list == NULL:
- # off = offset
- # item_addr = slot.ref_list.refs[off]
- # return self.collection[<object>item_addr]
+ address = <object>self._obj.ref_list.refs[off]
+ try:
+ return self.collection[address]
+ except KeyError:
+ # TODO: What to do if the object isn't present? I think returning a
+ # 'no-such-object' proxy would be nicer than returning nothing
+ raise
cdef class MemObjectCollection:
More information about the bazaar-commits
mailing list