[ZODB-Dev] Raw serial string in exception message
Greg Ward
gward@mems-exchange.org
Fri, 18 Jan 2002 14:54:03 -0500
On 18 January 2002, Andrew Kuchling said:
> In the current CVS FileStorage.py, there's code like this:
>
> pos=U64(prev)
> if not pos: raise KeyError, serial
> continue
>
> It doesn't look like this KeyError is ever caught, so if you trigger
> it, you get this output:
>
> Resolution.py", line 36, in state
> p=p or self.loadSerial(oid, serial)
> File "/home/akuchlin/src/StandaloneZODB/build/lib.linux-i686-2.2/ZODB/FileStorage.py", line 586, in loadSerial
> if not pos or 1: raise KeyError, serial
> KeyError: B}๐าก"
Oh good, I'm not the only one who's bothered by that. AFAICT, the only
reason to raise the exception that way is that it's consistent with how
Python raises KeyError:
>>> d = {}
>>> d['foo']
Traceback (most recent call last):
File "<stdin>", line 1, in ?
KeyError: foo
But I think that's pretty thin. +1 on changing serial to repr(serial)
there.
Greg