Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix mypy for ctypes.get_last_error
  • Loading branch information
chris-eibl committed Apr 24, 2025
commit 3d1da666ba77d7de9761eb51fc79b0696ef98718
9 changes: 6 additions & 3 deletions Lib/_pyrepl/windows_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@
from .windows_eventqueue import EventQueue

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

def GetLastError() -> int:
return 42

def get_last_error() -> int:
return 42

class WinError(OSError): # type: ignore[no-redef]
def __init__(self, err: int | None, descr: str | None = None) -> None:
self.err = err
Expand Down Expand Up @@ -416,7 +419,7 @@ def _read_input(self, block: bool = True) -> INPUT_RECORD | None:
if not block:
ret = WaitForSingleObject(InHandle, 0)
if ret == WAIT_FAILED:
raise WinError(ctypes.get_last_error())
raise WinError(get_last_error())
elif ret == WAIT_TIMEOUT:
return None

Expand Down Expand Up @@ -532,7 +535,7 @@ def wait(self, timeout: float | None) -> bool:
timeout = int(timeout)
ret = WaitForSingleObject(InHandle, timeout)
if ret == WAIT_FAILED:
raise WinError(ctypes.get_last_error())
raise WinError(get_last_error())
Comment thread
tomasr8 marked this conversation as resolved.

def repaint(self) -> None:
raise NotImplementedError("No repaint support")
Expand Down