Skip to content

Commit c3643a1

Browse files
authored
pythongh-118817: Fix asyncio REPL on Windows (python#118819)
1 parent 35b5eaa commit c3643a1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Lib/asyncio/__main__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def run(self):
108108
try:
109109
import readline # NoQA
110110
except ImportError:
111-
pass
111+
readline = None
112112

113113
interactive_hook = getattr(sys, "__interactivehook__", None)
114114

@@ -122,8 +122,9 @@ def run(self):
122122
except:
123123
pass
124124
else:
125-
completer = rlcompleter.Completer(console.locals)
126-
readline.set_completer(completer.complete)
125+
if readline is not None:
126+
completer = rlcompleter.Completer(console.locals)
127+
readline.set_completer(completer.complete)
127128

128129
repl_thread = REPLThread()
129130
repl_thread.daemon = True

Lib/test/test_repl.py

+4-1
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
10+
from test.support.script_helper import kill_python, assert_python_ok
1111
from test.support.import_helper import import_module
1212

1313

@@ -195,6 +195,9 @@ 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")
200+
198201

199202

200203
class TestInteractiveModeSyntaxErrors(unittest.TestCase):

0 commit comments

Comments
 (0)