Bug report
Bug description:
There is a small bug in _pyrepl.unix_console.UnixConsole.getpending, where instead of adding the raw data of event 2, we add the raw data of event 1 to itself:
|
e = Event("key", "", b"") |
|
|
|
while not self.event_queue.empty(): |
|
e2 = self.event_queue.get() |
|
e.data += e2.data |
|
e.raw += e.raw |
|
|
We can just fix the typo: e.raw += e.raw becomes e.raw += e2.raw. It's feasible to add a test for this.
But Event.raw isn't read anywhere and is untested. The 3 callers of getpending() only use ev.data or pending.data. The .raw field is only written to, never consumed. So we can simply remove it from Event and adapt some lines (summary below written with Claude Code).
Please let me know which solution is preferred and I can write a trivial PR to implement it.
Since .raw is never read by any consumer, it's dead code. This removes the field and all assignments to it:
console.py — Remove raw from the dataclass:
@dataclass
class Event:
evt: str
data: str
unix_console.py — Remove all raw-related code in both getpending variants:
- Line 540:
Event("key", "", b"") → Event("key", "")
- Line 545: delete
e.raw += e.raw
- Line 549-550:
raw = ... / data = str(raw, ...) → data = str(self.__read(amount), ...)
- Line 552: delete
e.raw += raw
- Same changes for lines 564, 569, 572-575
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
There is a small bug in
_pyrepl.unix_console.UnixConsole.getpending, where instead of adding the raw data of event 2, we add the raw data of event 1 to itself:cpython/Lib/_pyrepl/unix_console.py
Lines 540 to 546 in cd52172
We can just fix the typo:
e.raw += e.rawbecomese.raw += e2.raw. It's feasible to add a test for this.But
Event.rawisn't read anywhere and is untested. The 3 callers ofgetpending()only useev.dataorpending.data. The.rawfield is only written to, never consumed. So we can simply remove it fromEventand adapt some lines (summary below written with Claude Code).Please let me know which solution is preferred and I can write a trivial PR to implement it.
Since
.rawis never read by any consumer, it's dead code. This removes the field and all assignments to it:console.py— Removerawfrom the dataclass:unix_console.py— Remove allraw-related code in bothgetpendingvariants:Event("key", "", b"")→Event("key", "")e.raw += e.rawraw = .../data = str(raw, ...)→data = str(self.__read(amount), ...)e.raw += rawCPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs