[3.13] gh-121790: Fix interactive console initialization (GH-121793) (GH-121822)

(cherry picked from commit e5c7216f37)

Co-authored-by: Milan Oberkirch <milan.oberkirch@geops.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
Miss Islington (bot) 2024-07-16 00:49:41 +02:00 committed by GitHub
parent 0794220a69
commit 5b718e7fc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 85 additions and 42 deletions

View file

@ -27,12 +27,9 @@ from __future__ import annotations
import _sitebuiltins
import linecache
import builtins
import sys
import code
from types import ModuleType
from .console import InteractiveColoredConsole
from .readline import _get_reader, multiline_input
TYPE_CHECKING = False
@ -82,17 +79,12 @@ REPL_COMMANDS = {
def run_multiline_interactive_console(
namespace: dict[str, Any],
console: code.InteractiveConsole,
*,
future_flags: int = 0,
console: code.InteractiveConsole | None = None,
) -> None:
from .readline import _setup
_setup(namespace)
if console is None:
console = InteractiveColoredConsole(
namespace, filename="<stdin>"
)
_setup(console.locals)
if future_flags:
console.compile.compiler.flags |= future_flags