From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:24:52 +0000 (+0200) Subject: [3.13] gh-121711: Set `-m asyncio` return_code to 1 for ENOTTY (GH-121714) (GH-121718) X-Git-Tag: v3.13.0b4~65 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f0c29a2d9f1df101efed8cda643bfff732c4e36b;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-121711: Set `-m asyncio` return_code to 1 for ENOTTY (GH-121714) (GH-121718) Set return_code to 1 for ENOTTY (cherry picked from commit a1834742936a3a2164c25c14ecf4ae6a95288ca3) Co-authored-by: Milan Oberkirch --- diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py index 3e2fe93943d4..95147171c2b7 100644 --- a/Lib/asyncio/__main__.py +++ b/Lib/asyncio/__main__.py @@ -106,7 +106,8 @@ class REPLThread(threading.Thread): if os.getenv("PYTHON_BASIC_REPL"): raise RuntimeError("user environment requested basic REPL") if not os.isatty(sys.stdin.fileno()): - raise OSError(errno.ENOTTY, "tty required", "stdin") + return_code = errno.ENOTTY + raise OSError(return_code, "tty required", "stdin") # This import will fail on operating systems with no termios. from _pyrepl.simple_interact import ( diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py index 1caf09ceaf10..0e73fb6249c7 100644 --- a/Lib/test/test_repl.py +++ b/Lib/test/test_repl.py @@ -7,7 +7,7 @@ import unittest from textwrap import dedent from test import support from test.support import cpython_only, has_subprocess_support, SuppressCrashReport -from test.support.script_helper import kill_python, assert_python_ok +from test.support.script_helper import assert_python_failure, kill_python, assert_python_ok from test.support.import_helper import import_module @@ -195,8 +195,8 @@ class TestInteractiveInterpreter(unittest.TestCase): expected = "(30, None, [\'def foo(x):\\n\', \' return x + 1\\n\', \'\\n\'], \'\')" self.assertIn(expected, output, expected) - def test_asyncio_repl_is_ok(self): - assert_python_ok("-m", "asyncio") + def test_asyncio_repl_no_tty_fails(self): + assert assert_python_failure("-m", "asyncio") class TestInteractiveModeSyntaxErrors(unittest.TestCase):