From: Zooko O'Whielacronx Date: Mon, 22 Dec 2008 23:22:37 +0000 (-0700) Subject: util/base32: loosen the precondition forbidding unicode and requiring str -- now... X-Git-Url: https://git.rkrishnan.org/vdrive/%22news.html/about.html?a=commitdiff_plain;h=dde2376c4e2d85ba2dc8a9b71f44a17682d49574;p=tahoe-lafs%2Ftahoe-lafs.git 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. --- diff --git a/src/allmydata/util/base32.py b/src/allmydata/util/base32.py index c5e5017e..148a869c 100644 --- a/src/allmydata/util/base32.py +++ b/src/allmydata/util/base32.py @@ -179,12 +179,13 @@ def init_s5(): s5 = init_s5() def could_be_base32_encoded(s, s8=s8, tr=string.translate, identitytranstable=identitytranstable, chars=chars): + precondition(isinstance(s, (str, unicode)), s) 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): + precondition(isinstance(s, (str, unicode)), s) if s == '': return True assert lengthinbits%5 < len(s5), lengthinbits