On Sep 21, 9:48 pm, Emmanuel  Lambert <elamb...@gmail.com> wrote:
> Hi,
>
> Has anyone a solution for the KeyError problem in Weave?

Hello. I also came across this problem (scipy 0.7.1 and 32 bit Mac OS
X) and found a simple solution. You need to apply the following patch
to the file scipy/io/dumbdb_patched.py:

--- dumbdbm_patched.py  2009-09-25 05:28:21.000000000 +0300
+++ dumbdbm_patched_fixed.py    2009-09-25 05:26:18.000000000 +0300
@@ -70,7 +70,10 @@
         f.close()

     def __getitem__(self, key):
-        pos, siz = self._index[key] # may raise KeyError
+        try:
+            pos, siz = self._index[key] # may raise KeyError
+        except KeyError:
+            raise IndexError
         f = _open(self._datfile, 'rb')
         f.seek(pos)
         dat = f.read(siz)

For some reason the code didn't handle the case where __getitem__ is
called for key that is out of bounds. Maybe __getitem__'s expected
behaviour has changed in Python 2.6 or something. Anyways, with this
change I got weave.inline working again (both the toy example in this
thread and my own project).

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to