From 71cd972d9c307cc4c7de213f636596d3bead8cd5 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Thu, 9 May 2024 11:15:26 +0300 Subject: [PATCH 1/3] Fix `asyncio REPL` on Windows --- Lib/asyncio/__main__.py | 7 ++++--- Lib/test/test_repl.py | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py index cbc1d7c93ef76f..9041b8b8316c1e 100644 --- a/Lib/asyncio/__main__.py +++ b/Lib/asyncio/__main__.py @@ -108,7 +108,7 @@ def run(self): try: import readline # NoQA except ImportError: - pass + readline = None interactive_hook = getattr(sys, "__interactivehook__", None) @@ -122,8 +122,9 @@ def run(self): except: pass else: - completer = rlcompleter.Completer(console.locals) - readline.set_completer(completer.complete) + if readline is not None: + completer = rlcompleter.Completer(console.locals) + readline.set_completer(completer.complete) repl_thread = REPLThread() repl_thread.daemon = True diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py index 457279a4db687d..bc2d99d175ab3b 100644 --- a/Lib/test/test_repl.py +++ b/Lib/test/test_repl.py @@ -7,7 +7,7 @@ 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 +from test.support.script_helper import kill_python, assert_python_ok from test.support.import_helper import import_module @@ -194,6 +194,10 @@ def bar(x): self.assertEqual(p.returncode, 0) 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") + From ebedccfc393de3b8ce0428bbdb54e8fd1899a09f Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Thu, 9 May 2024 11:21:18 +0300 Subject: [PATCH 2/3] Remove accidentally added newline --- Lib/test/test_repl.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py index bc2d99d175ab3b..bb1ea65720a1a1 100644 --- a/Lib/test/test_repl.py +++ b/Lib/test/test_repl.py @@ -200,7 +200,6 @@ def test_asyncio_repl_is_ok(self): - class TestInteractiveModeSyntaxErrors(unittest.TestCase): def test_interactive_syntax_error_correct_line(self): From 729d11ec02753f601df54e8767680e25d3931883 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Thu, 9 May 2024 11:23:10 +0300 Subject: [PATCH 3/3] Remove accidentally added tab... --- Lib/test/test_repl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py index bb1ea65720a1a1..340178366fc13a 100644 --- a/Lib/test/test_repl.py +++ b/Lib/test/test_repl.py @@ -194,7 +194,7 @@ def bar(x): self.assertEqual(p.returncode, 0) 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")