diff -r aea58e1cae75 Lib/uu.py --- a/Lib/uu.py Sun Sep 08 14:14:38 2013 +0200 +++ b/Lib/uu.py Sun Sep 08 20:20:04 2013 +0300 @@ -160,23 +160,19 @@ def test(): """uuencode/uudecode main program""" - import optparse - parser = optparse.OptionParser(usage='usage: %prog [-d] [-t] [input [output]]') - parser.add_option('-d', '--decode', dest='decode', help='Decode (instead of encode)?', default=False, action='store_true') - parser.add_option('-t', '--text', dest='text', help='data is text, encoded format unix-compatible text?', default=False, action='store_true') + import argparse + parser = argparse.ArgumentParser() + parser.add_argument('-d', '--decode', action='store_true', + help='Decode (instead of encode)?') + parser.add_argument('-t', '--text', action='store_true', + help='data is text, encoded format unix-compatible ' + 'text?') + parser.add_argument('input', nargs='?', default=sys.stdin.buffer) + parser.add_argument('output', nargs='?', default=sys.stdout.buffer) - (options, args) = parser.parse_args() - if len(args) > 2: - parser.error('incorrect number of arguments') - sys.exit(1) - - # Use the binary streams underlying stdin/stdout - input = sys.stdin.buffer - output = sys.stdout.buffer - if len(args) > 0: - input = args[0] - if len(args) > 1: - output = args[1] + options = parser.parse_args() + input = options.input + output = options.output if options.decode: if options.text: