MCPcopy Index your code
hub / github.com/python/cpython / getpending

Method getpending

Lib/_pyrepl/windows_console.py:524–551  ·  view source on GitHub ↗

Return the characters that have been typed but not yet processed.

(self)

Source from the content-addressed store, hash-verified

522 raise WinError(get_last_error())
523
524 def getpending(self) -> Event:
525 """Return the characters that have been typed but not yet
526 processed."""
527 e = Event("key", "", b"")
528
529 while not self.event_queue.empty():
530 e2 = self.event_queue.get()
531 if e2:
532 e.data += e2.data
533
534 recs, rec_count = self._read_input_bulk(1024)
535 for i in range(rec_count):
536 rec = recs[i]
537 # In case of a legacy console, we do not only receive a keydown
538 # event, but also a keyup event - and for uppercase letters
539 # an additional SHIFT_PRESSED event.
540 if rec and rec.EventType == KEY_EVENT:
541 key_event = rec.Event.KeyEvent
542 if not key_event.bKeyDown:
543 continue
544 ch = key_event.uChar.UnicodeChar
545 if ch == "\x00":
546 # ignore SHIFT_PRESSED and special keys
547 continue
548 if ch == "\r":
549 ch += "\n"
550 e.data += ch
551 return e
552
553 def wait_for_event(self, timeout: float | None) -> bool:
554 """Wait for an event."""

Callers

nothing calls this directly

Calls 4

_read_input_bulkMethod · 0.95
EventClass · 0.70
emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected