summaryrefslogtreecommitdiffstats
path: root/Lib/uu.py
diff options
context:
space:
mode:
authorXiang Zhang <angwerzx@126.com>2017-05-03 03:16:21 (GMT)
committerGitHub <noreply@github.com>2017-05-03 03:16:21 (GMT)
commit13f1f423fac39f8f14a3ce919dd236975517d5c6 (patch)
tree674546ddbbbfaf930c0087eeb1621fab11e25d5f /Lib/uu.py
parent0360a9d015ddbc4e3d58e3ab4b433da27bf1db3a (diff)
downloadcpython-13f1f423fac39f8f14a3ce919dd236975517d5c6.zip
cpython-13f1f423fac39f8f14a3ce919dd236975517d5c6.tar.gz
cpython-13f1f423fac39f8f14a3ce919dd236975517d5c6.tar.bz2
bpo-30103: Allow Uuencode in Python using backtick as zero instead of space (#1326)
Diffstat (limited to 'Lib/uu.py')
-rwxr-xr-xLib/uu.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/uu.py b/Lib/uu.py
index d68d293..8333e86 100755
--- a/Lib/uu.py
+++ b/Lib/uu.py
@@ -26,8 +26,8 @@
"""Implementation of the UUencode and UUdecode functions.
-encode(in_file, out_file [,name, mode])
-decode(in_file [, out_file, mode])
+encode(in_file, out_file [,name, mode], *, backtick=False)
+decode(in_file [, out_file, mode, quiet])
"""
import binascii
@@ -39,7 +39,7 @@ __all__ = ["Error", "encode", "decode"]
class Error(Exception):
pass
-def encode(in_file, out_file, name=None, mode=None):
+def encode(in_file, out_file, name=None, mode=None, *, backtick=False):
"""Uuencode file"""
#
# If in_file is a pathname open it and change defaults
@@ -79,9 +79,12 @@ def encode(in_file, out_file, name=None, mode=None):
out_file.write(('begin %o %s\n' % ((mode & 0o777), name)).encode("ascii"))
data = in_file.read(45)
while len(data) > 0:
- out_file.write(binascii.b2a_uu(data))
+ out_file.write(binascii.b2a_uu(data, backtick=backtick))
data = in_file.read(45)
- out_file.write(b' \nend\n')
+ if backtick:
+ out_file.write(b'`\nend\n')
+ else:
+ out_file.write(b' \nend\n')
finally:
for f in opened_files:
f.close()