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.
This commit is contained in:
robk-tahoe 2008-02-14 17:23:07 -07:00
parent 09bfa3bea2
commit ca41693162

View File

@ -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):