https://github.com/python/cpython/commit/738877a1013f1752cb67c3e6a49121be5f656c72
commit: 738877a1013f1752cb67c3e6a49121be5f656c72
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: gvanrossum <[email protected]>
date: 2024-05-09T15:47:31Z
summary:

[3.13] gh-118817: Fix `asyncio REPL` on Windows (GH-118819) (#118847)

(cherry picked from commit c3643a121401d111bebd3e26d6f362ade2ed2a83)

Co-authored-by: Kirill Podoprigora <[email protected]>

files:
M Lib/asyncio/__main__.py
M Lib/test/test_repl.py

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..340178366fc13a 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
 
 
@@ -195,6 +195,9 @@ def bar(x):
         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):

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to