From: Georg Brandl Date: Sun, 19 Feb 2006 09:51:33 +0000 (+0000) Subject: Patch #1337756: fileinput now accepts Unicode filenames. X-Git-Tag: v2.4.3c1~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=044d2ce37c08f542c2c4f8b0ee4582ff06cbfb68;p=thirdparty%2FPython%2Fcpython.git Patch #1337756: fileinput now accepts Unicode filenames. --- diff --git a/Lib/fileinput.py b/Lib/fileinput.py index 27ccc3bfedfd..5c06627238ca 100644 --- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -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: diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py index 3a82c7c71f3f..285573cc8ec0 100644 --- a/Lib/test/test_fileinput.py +++ b/Lib/test/test_fileinput.py @@ -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) diff --git a/Misc/NEWS b/Misc/NEWS index 8c3dc3894808..02f49aecc8b7 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -74,6 +74,8 @@ Extension Modules Library ------- +- Patch #1337756: fileinput now accepts Unicode filenames. + - Patch #1373643: The chunk module can now read chunks larger than two gigabytes.