[ZODB-Dev] Raw serial string in exception message

Steve Alexander steve@cat-box.net
Fri, 18 Jan 2002 20:11:27 +0000


Greg Ward wrote:
> 
> 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

This example illustrates the difference better:

 >>> {}['foo\012bar']
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
KeyError: foo
bar

The example above shows that Python doesn't call repr on keys when 
raising a KeyError. Perhaps it should. I guess unprintable keys are less 
common in non-ZODB python apps.


> But I think that's pretty thin.  +1 on changing serial to repr(serial)
> there.

+1 from me.

--
Steve Alexander