REPOST: Suggested tweak to

Tim Roberts timr at
Sun Dec 30 22:21:43 CET 2001

Once in a while, I use the standard library module as a
standalone Base64 decoder.  However, there is a slight problem with this.
Most base64 attachments are encoded because they were binary files to begin
with.  The test() module writes its results to stdout, which on
Windows is a text file by default.  CR/LF and Ctrl-Z confusion ensues.

I'd like to suggest the following four lines be inserted just before the
end of base64.test():

        if o == '-t': test1(); return
+   if func == decode and sys.platform == 'win32':
+       import os
+       import msvcrt
+       msvcrt.setmode( sys.stdout.fileno(), os.O_BINARY )
    if args and args[0] != '-':
        func(open(args[0], 'rb'), sys.stdout)
        func(sys.stdin, sys.stdout)
- Tim Roberts, timr at
  Providenza & Boekelheide, Inc.

========= WAS CANCELLED BY =======:
From: Tim Roberts <timr at>
Newsgroups: comp.lang.python
Subject: cmsg cancel <r21v2u4cqti58i2269bqr8nh0a1i7s3ct5 at>
Control: cancel <r21v2u4cqti58i2269bqr8nh0a1i7s3ct5 at>
Date: Mon, 31 Dec 2001 02:31:15 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.r21v2u4cqti58i2269bqr8nh0a1i7s3ct5 at>
X-Trace: 1009774069 27193 (31 Dec 2001 04:47:49 GMT)
X-Complaints-To: usenet at
NNTP-Posting-Date: Mon, 31 Dec 2001 04:47:49 +0000 (UTC)
X-No-Archive: yes
X-Unac4ncel: yes
X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999)

This message was cancelled from within Mozilla.

More information about the Python-list mailing list