mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-120678: pyrepl: Include globals from modules passed with -i
(GH-120904)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
58753f33e4
commit
ac07451116
6 changed files with 178 additions and 11 deletions
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from code import InteractiveConsole
|
||||
from functools import partial
|
||||
from typing import Iterable
|
||||
|
@ -100,8 +101,18 @@ handle_events_narrow_console = partial(
|
|||
)
|
||||
|
||||
|
||||
def make_clean_env() -> dict[str, str]:
|
||||
clean_env = os.environ.copy()
|
||||
for k in clean_env.copy():
|
||||
if k.startswith("PYTHON"):
|
||||
clean_env.pop(k)
|
||||
clean_env.pop("FORCE_COLOR", None)
|
||||
clean_env.pop("NO_COLOR", None)
|
||||
return clean_env
|
||||
|
||||
|
||||
class FakeConsole(Console):
|
||||
def __init__(self, events, encoding="utf-8"):
|
||||
def __init__(self, events, encoding="utf-8") -> None:
|
||||
self.events = iter(events)
|
||||
self.encoding = encoding
|
||||
self.screen = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue