mirror of https://github.com/python/cpython
Patch #1337756: fileinput now accepts Unicode filenames.
This commit is contained in:
parent
e9b1949f70
commit
e466217ab9
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue