]> granicus.if.org Git - python/commitdiff
Patch #1337756: fileinput now accepts Unicode filenames.
authorGeorg Brandl <georg@python.org>
Sun, 19 Feb 2006 09:51:27 +0000 (09:51 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 19 Feb 2006 09:51:27 +0000 (09:51 +0000)
Lib/fileinput.py
Lib/test/test_fileinput.py
Misc/NEWS

index 27ccc3bfedfd7a5b2584258b86228f4df2f89c78..5c06627238ca88c5b3a629533cd4a7b0f44ea0d3 100644 (file)
@@ -184,7 +184,7 @@ class FileInput:
     """
 
     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:
index 3a82c7c71f3ffe3b27e8729a9164d7032e03384f..285573cc8ec04bd9ad8c6665b075b6f638868525 100644 (file)
@@ -157,3 +157,13 @@ try:
     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)
index 9f92bf4595c44a8440c05146d785f15db66a12b2..47bb57aad7b0457a8c3b26e449e35097870d2513 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -366,6 +366,8 @@ Extension Modules
 Library
 -------
 
+- Patch #1337756: fileinput now accepts Unicode filenames.
+
 - Patch #1373643: The chunk module can now read chunks larger than
   two gigabytes.