]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Incorporate fix suggested by /Fredrik Lundh in the newsgroup to cope
authorGuido van Rossum <guido@python.org>
Tue, 5 Jan 1999 18:02:24 +0000 (18:02 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 5 Jan 1999 18:02:24 +0000 (18:02 +0000)
with trailing garbage generated by some broke uuencoders.

Lib/uu.py

index ecd76a86282a19333135fc1cb146cc3df7a36235..0ca4ae5f2635bfb280aca45f28fb93987be97eda 100755 (executable)
--- a/Lib/uu.py
+++ b/Lib/uu.py
@@ -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'