From: robk-tahoe Date: Fri, 15 Feb 2008 00:23:07 +0000 (-0700) Subject: idlib: make failures much clearer when encountering unicode X-Git-Tag: allmydata-tahoe-0.8.0~52 X-Git-Url: https://git.rkrishnan.org/frontends/webapi.txt?a=commitdiff_plain;h=ca41693162cb8b66243e0b87fbe6928dbbea9b95;p=tahoe-lafs%2Ftahoe-lafs.git idlib: make failures much clearer when encountering unicode while investigating fuse related stuff, I spent quite a while staring at very cryptic explosions I got from idlib. it turns out that unicode objects and str objects have .translate() methods with differing signatures. to save anyone else the headache, this makes it very clear if you accidentally try to pass a unicode object in to a2b() etc. --- diff --git a/src/allmydata/util/base32.py b/src/allmydata/util/base32.py index 983ff194..c5e5017e 100644 --- a/src/allmydata/util/base32.py +++ b/src/allmydata/util/base32.py @@ -181,6 +181,7 @@ s5 = init_s5() def could_be_base32_encoded(s, s8=s8, tr=string.translate, identitytranstable=identitytranstable, chars=chars): if s == '': return True + precondition(not isinstance(s, unicode), s) return s8[len(s)%8][ord(s[-1])] and not tr(s, identitytranstable, chars) def could_be_base32_encoded_l(s, lengthinbits, s5=s5, tr=string.translate, identitytranstable=identitytranstable, chars=chars):