diff options
author | Xiang Zhang <angwerzx@126.com> | 2017-05-03 03:16:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-03 03:16:21 (GMT) |
commit | 13f1f423fac39f8f14a3ce919dd236975517d5c6 (patch) | |
tree | 674546ddbbbfaf930c0087eeb1621fab11e25d5f /Lib/uu.py | |
parent | 0360a9d015ddbc4e3d58e3ab4b433da27bf1db3a (diff) | |
download | cpython-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-x | Lib/uu.py | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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() |