From dde2376c4e2d85ba2dc8a9b71f44a17682d49574 Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Mon, 22 Dec 2008 16:22:37 -0700 Subject: [PATCH] =?utf8?q?util/base32:=20loosen=20the=20precondition=20for?= =?utf8?q?bidding=20unicode=20and=20requiring=20str=20--=20now=20it=20requ?= =?utf8?q?ires=20either=20unicode=20or=20str=20Hopefully=20this=20will=20m?= =?utf8?q?ake=20it=20so=20that=20tests=20pass=20with=20Fran=C3=A7ois=20Dep?= =?utf8?q?pierraz's=20patch=20to=20fix=20the=20tahoe=20cli's=20handling=20?= =?utf8?q?of=20unicode=20argument.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/allmydata/util/base32.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 -- 2.45.2