mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-20 03:36:25 +00:00
Python 3 compatibility
This commit is contained in:
parent
a223f6bb60
commit
895ba55cf7
@ -1071,9 +1071,9 @@ class Signatures(SyncTestCase):
|
|||||||
(msg, sig, key) = sign_to_foolscap(ann, private_key)
|
(msg, sig, key) = sign_to_foolscap(ann, private_key)
|
||||||
# Drop a base32 word from the middle of the key to invalidate the
|
# Drop a base32 word from the middle of the key to invalidate the
|
||||||
# signature.
|
# signature.
|
||||||
sig_l = list(sig)
|
sig_a = bytearray(sig)
|
||||||
sig_l[20:22] = []
|
sig_a[20:22] = []
|
||||||
sig = b"".join(sig_l)
|
sig = bytes(sig_a)
|
||||||
ann_t = (msg, sig, key)
|
ann_t = (msg, sig, key)
|
||||||
ic.got_announcements([ann_t])
|
ic.got_announcements([ann_t])
|
||||||
|
|
||||||
|
@ -140,7 +140,9 @@ def a2b(cs):
|
|||||||
# Add padding back, to make Python's base64 module happy:
|
# Add padding back, to make Python's base64 module happy:
|
||||||
while (len(cs) * 5) % 8 != 0:
|
while (len(cs) * 5) % 8 != 0:
|
||||||
cs += b"="
|
cs += b"="
|
||||||
return base64.b32decode(cs)
|
# Let newbytes come through and still work on Python 2, where the base64
|
||||||
|
# module gets confused by them.
|
||||||
|
return base64.b32decode(backwardscompat_bytes(cs))
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["b2a", "a2b", "b2a_or_none", "BASE32CHAR_3bits", "BASE32CHAR_1bits", "BASE32CHAR", "BASE32STR_anybytes", "could_be_base32_encoded"]
|
__all__ = ["b2a", "a2b", "b2a_or_none", "BASE32CHAR_3bits", "BASE32CHAR_1bits", "BASE32CHAR", "BASE32STR_anybytes", "could_be_base32_encoded"]
|
||||||
|
Loading…
Reference in New Issue
Block a user