From: Serhiy Storchaka Date: Thu, 24 Apr 2025 15:47:01 +0000 (+0300) Subject: [3.13] Use os.openpty() instead of pty.openpty() in test_ioctl (GH-132878) X-Git-Tag: v3.13.4~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf6c74dc7ab5ee3cc537a5082a75f4387ad64eeb;p=thirdparty%2FPython%2Fcpython.git [3.13] Use os.openpty() instead of pty.openpty() in test_ioctl (GH-132878) pty.openpty() does not work on Android, and it is easier to check availability of os.openpty. --- diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py index cc625812dc3d..17170a812024 100644 --- a/Lib/test/test_ioctl.py +++ b/Lib/test/test_ioctl.py @@ -9,11 +9,6 @@ from test.support.import_helper import import_module fcntl = import_module('fcntl') termios = import_module('termios') -try: - import pty -except ImportError: - pty = None - class IoctlTestsTty(unittest.TestCase): @classmethod def setUpClass(cls): @@ -136,10 +131,10 @@ class IoctlTestsTty(unittest.TestCase): self.assertRaises(ValueError, self._check_ioctl_not_mutate_len, 2048) -@unittest.skipIf(pty is None, 'pty module required') +@unittest.skipUnless(hasattr(os, 'openpty'), "need os.openpty()") class IoctlTestsPty(unittest.TestCase): def setUp(self): - self.master_fd, self.slave_fd = pty.openpty() + self.master_fd, self.slave_fd = os.openpty() self.addCleanup(os.close, self.slave_fd) self.addCleanup(os.close, self.master_fd)