Skip to content

Commit d77c46e

Browse files
committed
Use _winapi for _pyrepl console handles and waits
1 parent 26696a6 commit d77c46e

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

Lib/_pyrepl/windows_console.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
from .windows_eventqueue import EventQueue
5454

5555
try:
56-
from ctypes import get_last_error, WinDLL, windll, WinError # type: ignore[attr-defined]
56+
from ctypes import get_last_error, WinDLL, WinError # type: ignore[attr-defined]
5757
except:
5858
# Keep MyPy happy off Windows
59-
from ctypes import CDLL as WinDLL, cdll as windll
59+
from ctypes import CDLL as WinDLL
6060

6161
def get_last_error() -> int:
6262
return 42
@@ -796,11 +796,11 @@ class INPUT_RECORD(Structure):
796796
STD_OUTPUT_HANDLE = -11
797797

798798
if sys.platform == "win32":
799+
import _winapi
800+
799801
_KERNEL32 = WinDLL("kernel32", use_last_error=True)
800802

801-
GetStdHandle = windll.kernel32.GetStdHandle
802-
GetStdHandle.argtypes = [DWORD]
803-
GetStdHandle.restype = HANDLE
803+
GetStdHandle = _winapi.GetStdHandle
804804

805805
GetConsoleScreenBufferInfo = _KERNEL32.GetConsoleScreenBufferInfo
806806
GetConsoleScreenBufferInfo.argtypes = [
@@ -836,9 +836,7 @@ class INPUT_RECORD(Structure):
836836
FlushConsoleInputBuffer.argtypes = [HANDLE]
837837
FlushConsoleInputBuffer.restype = BOOL
838838

839-
WaitForSingleObject = _KERNEL32.WaitForSingleObject
840-
WaitForSingleObject.argtypes = [HANDLE, DWORD]
841-
WaitForSingleObject.restype = DWORD
839+
WaitForSingleObject = _winapi.WaitForSingleObject
842840

843841
OutHandle = GetStdHandle(STD_OUTPUT_HANDLE)
844842
InHandle = GetStdHandle(STD_INPUT_HANDLE)

0 commit comments

Comments
 (0)