Skip to content

Commit 8d3ef98

Browse files
committed
Use _winapi calls directly in _pyrepl
1 parent d77c46e commit 8d3ef98

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

Lib/_pyrepl/windows_console.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ def wait_for_event(self, timeout: float | None) -> bool:
696696
timeout = INFINITE
697697
else:
698698
timeout = int(timeout)
699-
ret = WaitForSingleObject(InHandle, timeout)
699+
ret = _winapi.WaitForSingleObject(InHandle, timeout)
700700
if ret == WAIT_FAILED:
701701
raise WinError(get_last_error())
702702
elif ret == WAIT_TIMEOUT:
@@ -800,8 +800,6 @@ class INPUT_RECORD(Structure):
800800

801801
_KERNEL32 = WinDLL("kernel32", use_last_error=True)
802802

803-
GetStdHandle = _winapi.GetStdHandle
804-
805803
GetConsoleScreenBufferInfo = _KERNEL32.GetConsoleScreenBufferInfo
806804
GetConsoleScreenBufferInfo.argtypes = [
807805
HANDLE,
@@ -836,22 +834,18 @@ class INPUT_RECORD(Structure):
836834
FlushConsoleInputBuffer.argtypes = [HANDLE]
837835
FlushConsoleInputBuffer.restype = BOOL
838836

839-
WaitForSingleObject = _winapi.WaitForSingleObject
840-
841-
OutHandle = GetStdHandle(STD_OUTPUT_HANDLE)
842-
InHandle = GetStdHandle(STD_INPUT_HANDLE)
837+
OutHandle = _winapi.GetStdHandle(STD_OUTPUT_HANDLE)
838+
InHandle = _winapi.GetStdHandle(STD_INPUT_HANDLE)
843839
else:
844840

845841
def _win_only(*args, **kwargs):
846842
raise NotImplementedError("Windows only")
847843

848-
GetStdHandle = _win_only
849844
GetConsoleScreenBufferInfo = _win_only
850845
ScrollConsoleScreenBuffer = _win_only
851846
GetConsoleMode = _win_only
852847
SetConsoleMode = _win_only
853848
ReadConsoleInput = _win_only
854849
FlushConsoleInputBuffer = _win_only
855-
WaitForSingleObject = _win_only
856850
OutHandle = 0
857851
InHandle = 0

0 commit comments

Comments
 (0)