MCPcopy Index your code
hub / github.com/python/cpython / __init__

Method __init__

Lib/_pyrepl/windows_console.py:133–171  ·  view source on GitHub ↗
(
        self,
        f_in: IO[bytes] | int = 0,
        f_out: IO[bytes] | int = 1,
        term: str = "",
        encoding: str = "",
    )

Source from the content-addressed store, hash-verified

131
132class WindowsConsole(Console):
133 def __init__(
134 self,
135 f_in: IO[bytes] | int = 0,
136 f_out: IO[bytes] | int = 1,
137 term: str = "",
138 encoding: str = "",
139 ):
140 super().__init__(f_in, f_out, term, encoding)
141
142 self.__vt_support = _supports_vt()
143
144 if self.__vt_support:
145 trace('console supports virtual terminal')
146
147 # Save original console modes so we can recover on cleanup.
148 original_input_mode = DWORD()
149 if not GetConsoleMode(InHandle, original_input_mode):
150 raise WinError(get_last_error())
151 trace(f'saved original input mode 0x{original_input_mode.value:x}')
152 self.__original_input_mode = original_input_mode.value
153
154 if not SetConsoleMode(
155 OutHandle,
156 ENABLE_WRAP_AT_EOL_OUTPUT
157 | ENABLE_PROCESSED_OUTPUT
158 | ENABLE_VIRTUAL_TERMINAL_PROCESSING,
159 ):
160 raise WinError(get_last_error())
161
162 self.screen: list[str] = []
163 self.width = 80
164 self.height = 25
165 self.__offset = 0
166 self.event_queue = EventQueue(encoding)
167 try:
168 self.out = io._WindowsConsoleIO(self.output_fd, "w") # type: ignore[attr-defined]
169 except ValueError:
170 # Console I/O is redirected, fallback...
171 self.out = None
172
173 def refresh(self, screen: list[str], c_xy: tuple[int, int]) -> None:
174 """

Callers

nothing calls this directly

Calls 7

traceFunction · 0.90
WinErrorFunction · 0.90
superClass · 0.85
_supports_vtFunction · 0.85
get_last_errorFunction · 0.85
EventQueueClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected