[Python-checkins] commit of r41493 - in python/trunk: Lib Misc

walter.doerwald@python.org walter.doerwald at python.org
Mon Nov 21 20:10:08 CET 2005


Author: walter.doerwald
Date: Mon Nov 21 20:10:07 2005
New Revision: 41493

Modified:
   python/trunk/Lib/uu.py
   python/trunk/Misc/NEWS
Log:
Use basestring instead of type.StringType for checking whether a input
or output file is a file name instead of a file object. This enables
unicode file names as arguments to uu.encode() and uu.decode().


Modified: python/trunk/Lib/uu.py
==============================================================================
--- python/trunk/Lib/uu.py	(original)
+++ python/trunk/Lib/uu.py	Mon Nov 21 20:10:07 2005
@@ -33,7 +33,6 @@
 import binascii
 import os
 import sys
-from types import StringType
 
 __all__ = ["Error", "encode", "decode"]
 
@@ -47,7 +46,7 @@
     #
     if in_file == '-':
         in_file = sys.stdin
-    elif isinstance(in_file, StringType):
+    elif isinstance(in_file, basestring):
         if name is None:
             name = os.path.basename(in_file)
         if mode is None:
@@ -61,7 +60,7 @@
     #
     if out_file == '-':
         out_file = sys.stdout
-    elif isinstance(out_file, StringType):
+    elif isinstance(out_file, basestring):
         out_file = open(out_file, 'w')
     #
     # Set defaults for name and mode
@@ -88,7 +87,7 @@
     #
     if in_file == '-':
         in_file = sys.stdin
-    elif isinstance(in_file, StringType):
+    elif isinstance(in_file, basestring):
         in_file = open(in_file)
     #
     # Read until a begin is encountered or we've exhausted the file
@@ -117,7 +116,7 @@
     #
     if out_file == '-':
         out_file = sys.stdout
-    elif isinstance(out_file, StringType):
+    elif isinstance(out_file, basestring):
         fp = open(out_file, 'wb')
         try:
             os.path.chmod(out_file, mode)
@@ -172,7 +171,7 @@
 
     if dopt:
         if topt:
-            if isinstance(output, StringType):
+            if isinstance(output, basestring):
                 output = open(output, 'w')
             else:
                 print sys.argv[0], ': cannot do -t to stdout'
@@ -180,7 +179,7 @@
         decode(input, output)
     else:
         if topt:
-            if isinstance(input, StringType):
+            if isinstance(input, basestring):
                 input = open(input, 'r')
             else:
                 print sys.argv[0], ': cannot do -t from stdin'

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Mon Nov 21 20:10:07 2005
@@ -551,6 +551,8 @@
 - Bug #1245379: Add "unicode-1-1-utf-7" as an alias for "utf-7" to
   ``encodings.aliases``.
 
+- ` uu.encode()`` and ``uu.decode()`` now support unicode filenames.
+
 Build
 -----
 


More information about the Python-checkins mailing list