[ZODB-Dev] Raw serial string in exception message

Andrew Kuchling akuchlin@mems-exchange.org
Fri, 18 Jan 2002 11:36:32 -0500


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}๐าก"

Sometimes you get control characters in the serial number string,
which is always entertaining.  Is there anything preventing changing
the exception to "raise KeyError, repr(serial)"?  There are also some
lines in FileStorage with 'raise KeyError, oid' that also don't use
the repr() of oid, but I think those KeyErrors get caught and are
never printed.

--amk                                                  (www.amk.ca)
As always, I'll leave it to a volunteer to experiment with this.
    -- Guido van Rossum, 20 Jan 1995


Index: FileStorage.py
===================================================================
RCS file: /cvs-repository/StandaloneZODB/ZODB/FileStorage.py,v
retrieving revision 1.77
diff -C2 -r1.77 FileStorage.py
*** FileStorage.py	17 Jan 2002 17:34:33 -0000	1.77
--- FileStorage.py	18 Jan 2002 16:36:20 -0000
***************
*** 584,588 ****
                  # Keep looking for serial
                  pos=U64(prev)
!                 if not pos: raise KeyError, serial
                  continue
  
--- 584,588 ----
                  # Keep looking for serial
                  pos=U64(prev)
!                 if not pos: raise KeyError, repr(serial)
                  continue