Skip to content

Commit 00babcd

Browse files
committed
prepare banner, exit message, local_exit before run pyrepl
1 parent e98d099 commit 00babcd

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

‎Lib/code.py‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,22 +224,6 @@ def interact(self, banner=None, exitmsg=None, *, use_pyrepl=False):
224224
variable is not set.
225225
226226
"""
227-
if use_pyrepl is None:
228-
use_pyrepl = not os.getenv('PYTHON_BASIC_REPL')
229-
230-
if use_pyrepl:
231-
try:
232-
from _pyrepl.main import CAN_USE_PYREPL
233-
if CAN_USE_PYREPL:
234-
from _pyrepl.simple_interact import (
235-
run_multiline_interactive_console,
236-
)
237-
run_multiline_interactive_console(self)
238-
return
239-
except ImportError:
240-
pass
241-
# Fall through to basic REPL if pyrepl is unavailable
242-
243227
try:
244228
sys.ps1
245229
delete_ps1_after = False
@@ -284,6 +268,21 @@ def interact(self, banner=None, exitmsg=None, *, use_pyrepl=False):
284268
builtins.quit = Quitter("quit")
285269

286270
try:
271+
if use_pyrepl is None:
272+
use_pyrepl = not os.getenv('PYTHON_BASIC_REPL')
273+
if use_pyrepl:
274+
try:
275+
from _pyrepl.main import CAN_USE_PYREPL
276+
if CAN_USE_PYREPL:
277+
from _pyrepl.simple_interact import (
278+
run_multiline_interactive_console,
279+
)
280+
run_multiline_interactive_console(self)
281+
return
282+
except ImportError:
283+
pass
284+
# Fall through to basic REPL if pyrepl is unavailable
285+
287286
while True:
288287
try:
289288
if more:

0 commit comments

Comments
 (0)