]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
util/base32: loosen the precondition forbidding unicode and requiring str -- now...
authorZooko O'Whielacronx <zooko@zooko.com>
Mon, 22 Dec 2008 23:22:37 +0000 (16:22 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Mon, 22 Dec 2008 23:22:37 +0000 (16:22 -0700)
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.

src/allmydata/util/base32.py

index c5e5017ed6774820122d5c7b53486bd9c36d0569..148a869c8e321b9433c2dffe2e60c890f1666fd3 100644 (file)
@@ -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