[Python-checkins] python/dist/src/Lib base64.py,1.16,1.16.4.1
akuchling@users.sourceforge.net
akuchling at users.sourceforge.net
Thu Jun 9 00:53:03 CEST 2005
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29883/Lib
Modified Files:
Tag: release24-maint
base64.py
Log Message:
[Patch #1171487, bug #1170331] Fix error in base64.b32decode when encoding a single null byte; test a null byte in all encodings to be sure it works
Index: base64.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/base64.py,v
retrieving revision 1.16
retrieving revision 1.16.4.1
diff -u -d -r1.16 -r1.16.4.1
--- base64.py 12 Feb 2004 17:35:05 -0000 1.16
+++ base64.py 8 Jun 2005 22:53:00 -0000 1.16.4.1
@@ -221,12 +221,14 @@
acc += _b32rev[c] << shift
shift -= 5
if shift < 0:
- parts.append(binascii.unhexlify(hex(acc)[2:-1]))
+ parts.append(binascii.unhexlify('%010x' % acc))
acc = 0
shift = 35
# Process the last, partial quanta
- last = binascii.unhexlify(hex(acc)[2:-1])
- if padchars == 1:
+ last = binascii.unhexlify('%010x' % acc)
+ if padchars == 0:
+ last = '' # No characters
+ elif padchars == 1:
last = last[:-1]
elif padchars == 3:
last = last[:-2]
@@ -234,7 +236,7 @@
last = last[:-3]
elif padchars == 6:
last = last[:-4]
- elif padchars <> 0:
+ else:
raise TypeError('Incorrect padding')
parts.append(last)
return EMPTYSTRING.join(parts)
More information about the Python-checkins
mailing list