Skip to content

Commit f0c29a2

Browse files
miss-islingtonzvyn
andauthored
[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 a183474) Co-authored-by: Milan Oberkirch <[email protected]>
1 parent 14c5bff commit f0c29a2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Lib/asyncio/__main__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def run(self):
106106
if os.getenv("PYTHON_BASIC_REPL"):
107107
raise RuntimeError("user environment requested basic REPL")
108108
if not os.isatty(sys.stdin.fileno()):
109-
raise OSError(errno.ENOTTY, "tty required", "stdin")
109+
return_code = errno.ENOTTY
110+
raise OSError(return_code, "tty required", "stdin")
110111

111112
# This import will fail on operating systems with no termios.
112113
from _pyrepl.simple_interact import (

Lib/test/test_repl.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from textwrap import dedent
88
from test import support
99
from test.support import cpython_only, has_subprocess_support, SuppressCrashReport
10-
from test.support.script_helper import kill_python, assert_python_ok
10+
from test.support.script_helper import assert_python_failure, kill_python, assert_python_ok
1111
from test.support.import_helper import import_module
1212

1313

@@ -195,8 +195,8 @@ def bar(x):
195195
expected = "(30, None, [\'def foo(x):\\n\', \' return x + 1\\n\', \'\\n\'], \'<stdin>\')"
196196
self.assertIn(expected, output, expected)
197197

198-
def test_asyncio_repl_is_ok(self):
199-
assert_python_ok("-m", "asyncio")
198+
def test_asyncio_repl_no_tty_fails(self):
199+
assert assert_python_failure("-m", "asyncio")
200200

201201

202202
class TestInteractiveModeSyntaxErrors(unittest.TestCase):

0 commit comments

Comments
 (0)