diff options
author | Guido van Rossum <guido@python.org> | 1999-01-05 18:02:24 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-01-05 18:02:24 (GMT) |
commit | 4494101858cdcc489281c1e22c3172b99ae2cb20 (patch) | |
tree | 78e164cf4a91a8c47c77e70dfadc77b9888c2539 /Lib | |
parent | 716a89c606ae15731125f75d31082598f79e5ae2 (diff) | |
download | cpython-4494101858cdcc489281c1e22c3172b99ae2cb20.zip cpython-4494101858cdcc489281c1e22c3172b99ae2cb20.tar.gz cpython-4494101858cdcc489281c1e22c3172b99ae2cb20.tar.bz2 |
Incorporate fix suggested by /Fredrik Lundh in the newsgroup to cope
with trailing garbage generated by some broke uuencoders.
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/uu.py | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -121,10 +121,17 @@ def decode(in_file, out_file=None, mode=None): # # Main decoding loop # - str = in_file.readline() - while str and str != 'end\n': - out_file.write(binascii.a2b_uu(str)) - str = in_file.readline() + s = in_file.readline() + while s and s != 'end\n': + try: + data = binascii.a2b_uu(s) + except binascii.Error, v: + # Workaround for broken uuencoders by /Fredrik Lundh + nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 + data = binascii.a2b_uu(s[:nbytes]) + sys.stderr.write("Warning: %s\n" % str(v)) + out_file.write(data) + s = in_file.readline() if not str: raise Error, 'Truncated input file' |