Issue #12451: Open files in binary mode in some tests when the text file is not
needed.
Remove also an unused variable (blank) in test_threading.
diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py
index d4d5a22..531c9af 100644
--- a/Lib/test/test_ioctl.py
+++ b/Lib/test/test_ioctl.py
@@ -7,7 +7,7 @@
get_attribute(termios, 'TIOCGPGRP') #Can't run tests without this feature
try:
- tty = open("/dev/tty", "r")
+ tty = open("/dev/tty", "rb")
except IOError:
raise unittest.SkipTest("Unable to open /dev/tty")
else:
@@ -30,7 +30,7 @@
# If this process has been put into the background, TIOCGPGRP returns
# the session ID instead of the process group id.
ids = (os.getpgrp(), os.getsid(0))
- with open("/dev/tty", "r") as tty:
+ with open("/dev/tty", "rb") as tty:
r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
rpgrp = struct.unpack("i", r)[0]
self.assertIn(rpgrp, ids)
@@ -47,7 +47,7 @@
self.assertEqual(len(buf) * intsize, nbytes) # sanity check
else:
buf.append(fill)
- with open("/dev/tty", "r") as tty:
+ with open("/dev/tty", "rb") as tty:
r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
rpgrp = buf[0]
self.assertEqual(r, 0)