Skip to content

Commit be327a7

Browse files
diefessondpgeorge
authored andcommitted
binascii: Implement newline param in function b2a_base64.
See: https://docs.python.org/3/library/binascii.html#binascii.b2a_base64
1 parent e7e8eff commit be327a7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

python-stdlib/binascii/binascii.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def a2b_base64(ascii):
331331
table_b2a_base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
332332

333333

334-
def b2a_base64(bin):
334+
def b2a_base64(bin, newline=True):
335335
"Base64-code line of data."
336336

337337
newlength = (len(bin) + 2) // 3
@@ -357,5 +357,6 @@ def b2a_base64(bin):
357357
elif leftbits == 4:
358358
res.append(table_b2a_base64[(leftchar & 0xF) << 2])
359359
res.append(PAD)
360-
res.append("\n")
360+
if newline:
361+
res.append("\n")
361362
return "".join(res).encode("ascii")

0 commit comments

Comments
 (0)