diff options
Diffstat (limited to 'Lib/test/test_ioctl.py')
-rw-r--r-- | Lib/test/test_ioctl.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py index ae965d8242b..531c9afbb58 100644 --- a/Lib/test/test_ioctl.py +++ b/Lib/test/test_ioctl.py @@ -1,13 +1,13 @@ import array import unittest -from test.test_support import run_unittest, import_module, get_attribute +from test.support import run_unittest, import_module, get_attribute import os, struct fcntl = import_module('fcntl') termios = import_module('termios') 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,10 +30,10 @@ class IoctlTests(unittest.TestCase): # 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)) - tty = open("/dev/tty", "r") - r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ") - rpgrp = struct.unpack("i", r)[0] - self.assertIn(rpgrp, ids) + with open("/dev/tty", "rb") as tty: + r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ") + rpgrp = struct.unpack("i", r)[0] + self.assertIn(rpgrp, ids) def _check_ioctl_mutate_len(self, nbytes=None): buf = array.array('i') @@ -47,7 +47,7 @@ class IoctlTests(unittest.TestCase): 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) @@ -72,7 +72,7 @@ class IoctlTests(unittest.TestCase): try: if termios.TIOCSWINSZ < 0: set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ - set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffffL + set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffff else: set_winsz_opcode_pos = termios.TIOCSWINSZ set_winsz_opcode_maybe_neg, = struct.unpack("i", |