]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-118817: Fix `asyncio REPL` on Windows (#118819)
authorKirill Podoprigora <kirill.bast9@mail.ru>
Thu, 9 May 2024 15:20:46 +0000 (18:20 +0300)
committerGitHub <noreply@github.com>
Thu, 9 May 2024 15:20:46 +0000 (08:20 -0700)
Lib/asyncio/__main__.py
Lib/test/test_repl.py

index cbc1d7c93ef76f5b01e5019bc300a218f79b1717..9041b8b8316c1e4cd8bdae9ba2e09ce46ea7dbe5 100644 (file)
@@ -108,7 +108,7 @@ if __name__ == '__main__':
     try:
         import readline  # NoQA
     except ImportError:
-        pass
+        readline = None
 
     interactive_hook = getattr(sys, "__interactivehook__", None)
 
@@ -122,8 +122,9 @@ if __name__ == '__main__':
         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
index 457279a4db687df8e7fa8ed90ea3677f7d6d9bf5..340178366fc13ac91d36f24e7d649ad5b2b78abd 100644 (file)
@@ -7,7 +7,7 @@ import subprocess
 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
 
 
@@ -195,6 +195,9 @@ class TestInteractiveInterpreter(unittest.TestCase):
         expected = "(30, None, [\'def foo(x):\\n\', \'    return x + 1\\n\', \'\\n\'], \'<stdin>\')"
         self.assertIn(expected, output, expected)
 
+    def test_asyncio_repl_is_ok(self):
+        assert_python_ok("-m", "asyncio")
+
 
 
 class TestInteractiveModeSyntaxErrors(unittest.TestCase):