Kaydet (Commit) 62c11155 authored tarafından Guido van Rossum's avatar Guido van Rossum

Adapted version of SF Patch #103173 by pyretic: make uu.decode work

with spaces in filename.

I changed the module to use string methods instead of the string
module.  Also, instead of stripping the last character of the filename
(assuming this is the linefeed), I strip trailing whitespace (assuming
creating files with trailing whitespace in their name cannot possibly
be a wise idea).

(Note that I believe that /F's "workaround for broken uuencoders" is
no longer needed since the recent fix to binascii.c, but I'll leave it
in since it appears pretty harmless.)
üst 3d15bd88
...@@ -32,7 +32,6 @@ decode(in_file [, out_file, mode]) ...@@ -32,7 +32,6 @@ decode(in_file [, out_file, mode])
import binascii import binascii
import os import os
import string
import sys import sys
class Error(Exception): class Error(Exception):
...@@ -97,17 +96,17 @@ def decode(in_file, out_file=None, mode=None): ...@@ -97,17 +96,17 @@ def decode(in_file, out_file=None, mode=None):
raise Error, 'No valid begin line found in input file' raise Error, 'No valid begin line found in input file'
if hdr[:5] != 'begin': if hdr[:5] != 'begin':
continue continue
hdrfields = string.split(hdr) hdrfields = hdr.split(" ", 2)
if len(hdrfields) == 3 and hdrfields[0] == 'begin': if len(hdrfields) == 3 and hdrfields[0] == 'begin':
try: try:
string.atoi(hdrfields[1], 8) int(hdrfields[1], 8)
break break
except ValueError: except ValueError:
pass pass
if out_file is None: if out_file is None:
out_file = hdrfields[2] out_file = hdrfields[2].rstrip()
if mode is None: if mode is None:
mode = string.atoi(hdrfields[1], 8) mode = int(hdrfields[1], 8)
# #
# Open the output file # Open the output file
# #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment