Skip to content

Commit 3d1da66

Browse files
committed
fix mypy for ctypes.get_last_error
1 parent cad6bfb commit 3d1da66

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Lib/_pyrepl/windows_console.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@
4242
from .windows_eventqueue import EventQueue
4343

4444
try:
45-
from ctypes import GetLastError, WinDLL, windll, WinError # type: ignore[attr-defined]
45+
from ctypes import get_last_error, GetLastError, WinDLL, windll, WinError # type: ignore[attr-defined]
4646
except:
4747
# Keep MyPy happy off Windows
4848
from ctypes import CDLL as WinDLL, cdll as windll
4949

5050
def GetLastError() -> int:
5151
return 42
5252

53+
def get_last_error() -> int:
54+
return 42
55+
5356
class WinError(OSError): # type: ignore[no-redef]
5457
def __init__(self, err: int | None, descr: str | None = None) -> None:
5558
self.err = err
@@ -416,7 +419,7 @@ def _read_input(self, block: bool = True) -> INPUT_RECORD | None:
416419
if not block:
417420
ret = WaitForSingleObject(InHandle, 0)
418421
if ret == WAIT_FAILED:
419-
raise WinError(ctypes.get_last_error())
422+
raise WinError(get_last_error())
420423
elif ret == WAIT_TIMEOUT:
421424
return None
422425

@@ -532,7 +535,7 @@ def wait(self, timeout: float | None) -> bool:
532535
timeout = int(timeout)
533536
ret = WaitForSingleObject(InHandle, timeout)
534537
if ret == WAIT_FAILED:
535-
raise WinError(ctypes.get_last_error())
538+
raise WinError(get_last_error())
536539

537540
def repaint(self) -> None:
538541
raise NotImplementedError("No repaint support")

0 commit comments

Comments
 (0)