From ca41693162cb8b66243e0b87fbe6928dbbea9b95 Mon Sep 17 00:00:00 2001 From: robk-tahoe Date: Thu, 14 Feb 2008 17:23:07 -0700 Subject: [PATCH] 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. --- src/allmydata/util/base32.py | 1 + 1 file changed, 1 insertion(+) 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): -- 2.45.2