Skip to content

Commit

Permalink
Repair new test failures on Windows due to
Browse files Browse the repository at this point in the history
implicit assumptions that there's no difference
between text and binary modes.
  • Loading branch information
tim-one committed Feb 19, 2006
1 parent 6302a5a commit 4d7cad1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lib/test/test_fileinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

# Write lines (a list of lines) to temp file number i, and return the
# temp file's name.
def writeTmp(i, lines):
def writeTmp(i, lines, mode='w'): # opening in text mode is the default
name = TESTFN + str(i)
f = open(name, 'w')
f = open(name, mode)
f.writelines(lines)
f.close()
return name
Expand Down Expand Up @@ -194,7 +194,7 @@ def writeFiles():
pass
try:
# try opening in universal newline mode
t1 = writeTmp(1, ["A\nB\r\nC\rD"])
t1 = writeTmp(1, ["A\nB\r\nC\rD"], mode="wb")
fi = FileInput(files=t1, mode="U")
lines = list(fi)
verify(lines == ["A\n", "B\n", "C\n", "D"])
Expand All @@ -216,7 +216,7 @@ def writeFiles():
except ValueError:
pass
try:
t1 = writeTmp(1, ["A\nB"])
t1 = writeTmp(1, ["A\nB"], mode="wb")
fi = FileInput(files=t1, openhook=hook_encoded("rot13"))
lines = list(fi)
verify(lines == ["N\n", "O"])
Expand Down

0 comments on commit 4d7cad1

Please sign in to comment.