diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 4e793f15494..585affcd385 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -386,7 +386,7 @@ def skip_if_buildbot(reason=None): reason = 'not suitable for buildbots' try: isbuildbot = getpass.getuser().lower() == 'buildbot' - except (KeyError, EnvironmentError) as err: + except (KeyError, OSError) as err: warnings.warn(f'getpass.getuser() failed {err}.', RuntimeWarning) isbuildbot = False return unittest.skipIf(isbuildbot, reason) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index f77c6ecc050..4e8e85a5902 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1407,7 +1407,7 @@ class ProcessTestCase(BaseTestCase): t = threading.Thread(target=open_fds) t.start() try: - with self.assertRaises(EnvironmentError): + with self.assertRaises(OSError): subprocess.Popen(NONEXISTING_CMD, stdin=subprocess.PIPE, stdout=subprocess.PIPE,