mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Repair new test failures on Windows due to
implicit assumptions that there's no difference between text and binary modes.
This commit is contained in:
parent
6302a5a9b0
commit
4d7cad115d
1 changed files with 4 additions and 4 deletions
|
@ -15,9 +15,9 @@ from fileinput import FileInput, hook_encoded
|
||||||
|
|
||||||
# Write lines (a list of lines) to temp file number i, and return the
|
# Write lines (a list of lines) to temp file number i, and return the
|
||||||
# temp file's name.
|
# 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)
|
name = TESTFN + str(i)
|
||||||
f = open(name, 'w')
|
f = open(name, mode)
|
||||||
f.writelines(lines)
|
f.writelines(lines)
|
||||||
f.close()
|
f.close()
|
||||||
return name
|
return name
|
||||||
|
@ -194,7 +194,7 @@ except ValueError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
# try opening in universal newline mode
|
# 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")
|
fi = FileInput(files=t1, mode="U")
|
||||||
lines = list(fi)
|
lines = list(fi)
|
||||||
verify(lines == ["A\n", "B\n", "C\n", "D"])
|
verify(lines == ["A\n", "B\n", "C\n", "D"])
|
||||||
|
@ -216,7 +216,7 @@ try:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
t1 = writeTmp(1, ["A\nB"])
|
t1 = writeTmp(1, ["A\nB"], mode="wb")
|
||||||
fi = FileInput(files=t1, openhook=hook_encoded("rot13"))
|
fi = FileInput(files=t1, openhook=hook_encoded("rot13"))
|
||||||
lines = list(fi)
|
lines = list(fi)
|
||||||
verify(lines == ["N\n", "O"])
|
verify(lines == ["N\n", "O"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue