util/base32: loosen the precondition forbidding unicode and requiring str -- now it requires either unicode or str

Hopefully this will make it so that tests pass with François Deppierraz's patch to fix the tahoe cli's handling of unicode argument.
This commit is contained in:
Zooko O'Whielacronx 2008-12-22 16:22:37 -07:00
parent c54783f5e1
commit dde2376c4e
1 changed files with 2 additions and 1 deletions

View File

@ -179,12 +179,13 @@ def init_s5():
s5 = init_s5() s5 = init_s5()
def could_be_base32_encoded(s, s8=s8, tr=string.translate, identitytranstable=identitytranstable, chars=chars): def could_be_base32_encoded(s, s8=s8, tr=string.translate, identitytranstable=identitytranstable, chars=chars):
precondition(isinstance(s, (str, unicode)), s)
if s == '': if s == '':
return True return True
precondition(not isinstance(s, unicode), s)
return s8[len(s)%8][ord(s[-1])] and not tr(s, identitytranstable, chars) 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): def could_be_base32_encoded_l(s, lengthinbits, s5=s5, tr=string.translate, identitytranstable=identitytranstable, chars=chars):
precondition(isinstance(s, (str, unicode)), s)
if s == '': if s == '':
return True return True
assert lengthinbits%5 < len(s5), lengthinbits assert lengthinbits%5 < len(s5), lengthinbits