Skip to content

Commit f352fdd

Browse files
committed
Using get_last_error instead of GetLastError in windows_console.py
1 parent 8f45925 commit f352fdd

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Lib/_pyrepl/windows_console.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,11 @@
4343
from .windows_eventqueue import EventQueue
4444

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

51-
def GetLastError() -> int:
52-
return 42
53-
5451
def get_last_error() -> int:
5552
return 42
5653

@@ -301,7 +298,7 @@ def _scroll(
301298
if not ScrollConsoleScreenBuffer(
302299
OutHandle, scroll_rect, None, destination_origin, fill_info
303300
):
304-
raise WinError(GetLastError())
301+
raise WinError(get_last_error())
305302

306303
def _hide_cursor(self):
307304
self.__write("\x1b[?25l")
@@ -335,7 +332,7 @@ def __write(self, text: str) -> None:
335332
def screen_xy(self) -> tuple[int, int]:
336333
info = CONSOLE_SCREEN_BUFFER_INFO()
337334
if not GetConsoleScreenBufferInfo(OutHandle, info):
338-
raise WinError(GetLastError())
335+
raise WinError(get_last_error())
339336
return info.dwCursorPosition.X, info.dwCursorPosition.Y
340337

341338
def _erase_to_end(self) -> None:
@@ -394,7 +391,7 @@ def getheightwidth(self) -> tuple[int, int]:
394391
and width of the terminal window in characters."""
395392
info = CONSOLE_SCREEN_BUFFER_INFO()
396393
if not GetConsoleScreenBufferInfo(OutHandle, info):
397-
raise WinError(GetLastError())
394+
raise WinError(get_last_error())
398395
return (
399396
info.srWindow.Bottom - info.srWindow.Top + 1,
400397
info.srWindow.Right - info.srWindow.Left + 1,
@@ -403,15 +400,15 @@ def getheightwidth(self) -> tuple[int, int]:
403400
def _getscrollbacksize(self) -> int:
404401
info = CONSOLE_SCREEN_BUFFER_INFO()
405402
if not GetConsoleScreenBufferInfo(OutHandle, info):
406-
raise WinError(GetLastError())
403+
raise WinError(get_last_error())
407404

408405
return info.srWindow.Bottom # type: ignore[no-any-return]
409406

410407
def _read_input(self) -> INPUT_RECORD | None:
411408
rec = INPUT_RECORD()
412409
read = DWORD()
413410
if not ReadConsoleInput(InHandle, rec, 1, read):
414-
raise WinError(GetLastError())
411+
raise WinError(get_last_error())
415412

416413
return rec
417414

@@ -421,7 +418,7 @@ def _read_input_bulk(
421418
rec = (n * INPUT_RECORD)()
422419
read = DWORD()
423420
if not ReadConsoleInput(InHandle, rec, n, read):
424-
raise WinError(GetLastError())
421+
raise WinError(get_last_error())
425422

426423
return rec, read.value
427424

@@ -523,7 +520,7 @@ def flushoutput(self) -> None:
523520
def forgetinput(self) -> None:
524521
"""Forget all pending, but not yet processed input."""
525522
if not FlushConsoleInputBuffer(InHandle):
526-
raise WinError(GetLastError())
523+
raise WinError(get_last_error())
527524

528525
def getpending(self) -> Event:
529526
"""Return the characters that have been typed but not yet

0 commit comments

Comments
 (0)