[Python-checkins] r42490 - in python/branches/release24-maint: Lib/fileinput.py Lib/test/test_fileinput.py Misc/NEWS

georg.brandl python-checkins at python.org
Sun Feb 19 10:51:33 CET 2006


Author: georg.brandl
Date: Sun Feb 19 10:51:33 2006
New Revision: 42490

Modified:
   python/branches/release24-maint/Lib/fileinput.py
   python/branches/release24-maint/Lib/test/test_fileinput.py
   python/branches/release24-maint/Misc/NEWS
Log:
Patch #1337756: fileinput now accepts Unicode filenames.


Modified: python/branches/release24-maint/Lib/fileinput.py
==============================================================================
--- python/branches/release24-maint/Lib/fileinput.py	(original)
+++ python/branches/release24-maint/Lib/fileinput.py	Sun Feb 19 10:51:33 2006
@@ -184,7 +184,7 @@
     """
 
     def __init__(self, files=None, inplace=0, backup="", bufsize=0):
-        if type(files) == type(''):
+        if isinstance(files, basestring):
             files = (files,)
         else:
             if files is None:

Modified: python/branches/release24-maint/Lib/test/test_fileinput.py
==============================================================================
--- python/branches/release24-maint/Lib/test/test_fileinput.py	(original)
+++ python/branches/release24-maint/Lib/test/test_fileinput.py	Sun Feb 19 10:51:33 2006
@@ -157,3 +157,13 @@
     verify(fi.lineno() == 6)
 finally:
     remove_tempfiles(t1, t2)
+
+if verbose:
+    print "15. Unicode filenames"
+try:
+    t1 = writeTmp(1, ["A\nB"])
+    fi = FileInput(files=unicode(t1, sys.getfilesystemencoding()))
+    lines = list(fi)
+    verify(lines == ["A\n", "B"])
+finally:
+    remove_tempfiles(t1)

Modified: python/branches/release24-maint/Misc/NEWS
==============================================================================
--- python/branches/release24-maint/Misc/NEWS	(original)
+++ python/branches/release24-maint/Misc/NEWS	Sun Feb 19 10:51:33 2006
@@ -74,6 +74,8 @@
 Library
 -------
 
+- Patch #1337756: fileinput now accepts Unicode filenames.
+
 - Patch #1373643: The chunk module can now read chunks larger than
   two gigabytes.
 


More information about the Python-checkins mailing list