summaryrefslogtreecommitdiffstats
path: root/Lib/base64.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2021-09-20 18:22:55 (GMT)
committerGitHub <noreply@github.com>2021-09-20 18:22:55 (GMT)
commit9510e6f3c797b4398aaf58abc1072b9db0a644f9 (patch)
tree02cc57a588d356766df4bd191430c7cbdeca5a18 /Lib/base64.py
parent5846c9b71ee9277fe866b1bdee4cc6702323fe7e (diff)
downloadcpython-9510e6f3c797b4398aaf58abc1072b9db0a644f9.zip
cpython-9510e6f3c797b4398aaf58abc1072b9db0a644f9.tar.gz
cpython-9510e6f3c797b4398aaf58abc1072b9db0a644f9.tar.bz2
bpo-45155: Apply new byteorder default values for int.to/from_bytes (GH-28465)
Diffstat (limited to 'Lib/base64.py')
-rwxr-xr-xLib/base64.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/base64.py b/Lib/base64.py
index ffe2ce7..b25156d 100755
--- a/Lib/base64.py
+++ b/Lib/base64.py
@@ -182,7 +182,7 @@ def _b32encode(alphabet, s):
from_bytes = int.from_bytes
b32tab2 = _b32tab2[alphabet]
for i in range(0, len(s), 5):
- c = from_bytes(s[i: i + 5], 'big')
+ c = from_bytes(s[i: i + 5]) # big endian
encoded += (b32tab2[c >> 30] + # bits 1 - 10
b32tab2[(c >> 20) & 0x3ff] + # bits 11 - 20
b32tab2[(c >> 10) & 0x3ff] + # bits 21 - 30
@@ -234,13 +234,13 @@ def _b32decode(alphabet, s, casefold=False, map01=None):
acc = (acc << 5) + b32rev[c]
except KeyError:
raise binascii.Error('Non-base32 digit found') from None
- decoded += acc.to_bytes(5, 'big')
+ decoded += acc.to_bytes(5) # big endian
# Process the last, partial quanta
if l % 8 or padchars not in {0, 1, 3, 4, 6}:
raise binascii.Error('Incorrect padding')
if padchars and decoded:
acc <<= 5 * padchars
- last = acc.to_bytes(5, 'big')
+ last = acc.to_bytes(5) # big endian
leftover = (43 - 5 * padchars) // 8 # 1: 4, 3: 3, 4: 2, 6: 1
decoded[-5:] = last[:leftover]
return bytes(decoded)