diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 3aa74e3774c8c0..43a2219e067750 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -468,9 +468,9 @@ def test_stdout_flush_at_shutdown(self): rc, out, err = assert_python_failure('-c', code) self.assertEqual(b'', out) self.assertEqual(120, rc) - self.assertRegex(err.decode('ascii', 'ignore'), - r'Exception ignored on flushing sys\.stdout:\n' - r'OSError: .*') + self.assertIn(b'Exception ignored on flushing sys.stdout:\n' + b'OSError: '.replace(b'\n', os.linesep.encode()), + err) def test_closed_stdout(self): # Issue #13444: if stdout has been explicitly closed, we should