Skip to content

Commit 4098e3d

Browse files
committed
fix return value of wait() and use it in _read_input()
1 parent 3d1da66 commit 4098e3d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Lib/_pyrepl/windows_console.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,8 @@ def _getscrollbacksize(self) -> int:
416416
return info.srWindow.Bottom # type: ignore[no-any-return]
417417

418418
def _read_input(self, block: bool = True) -> INPUT_RECORD | None:
419-
if not block:
420-
ret = WaitForSingleObject(InHandle, 0)
421-
if ret == WAIT_FAILED:
422-
raise WinError(get_last_error())
423-
elif ret == WAIT_TIMEOUT:
424-
return None
419+
if not block and not self.wait(timeout=0):
420+
return None
425421

426422
rec = INPUT_RECORD()
427423
read = DWORD()
@@ -536,6 +532,9 @@ def wait(self, timeout: float | None) -> bool:
536532
ret = WaitForSingleObject(InHandle, timeout)
537533
if ret == WAIT_FAILED:
538534
raise WinError(get_last_error())
535+
elif ret == WAIT_TIMEOUT:
536+
return False
537+
return True
539538

540539
def repaint(self) -> None:
541540
raise NotImplementedError("No repaint support")

0 commit comments

Comments
 (0)