Skip to content

Commit 0feff68

Browse files
committed
simplify flush_buf() since raw is gone
no caller needs the buffer contents anymore, so just clear it without returning
1 parent 97e42b5 commit 0feff68

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Lib/_pyrepl/base_eventqueue.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ def empty(self) -> bool:
5454
"""
5555
return not self.events
5656

57-
def flush_buf(self) -> bytearray:
57+
def flush_buf(self) -> None:
5858
"""
59-
Flushes the buffer and returns its contents.
59+
Flushes the buffer.
6060
"""
61-
old = self.buf
6261
self.buf = bytearray()
63-
return old
6462

6563
def insert(self, event: Event) -> None:
6664
"""
@@ -98,7 +96,9 @@ def push(self, char: int | bytes) -> None:
9896
trace('unrecognized escape sequence, propagating...')
9997
self.keymap = self.compiled_keymap
10098
self.insert(Event('key', '\033'))
101-
for _c in self.flush_buf()[1:]:
99+
remaining = self.buf[1:]
100+
self.flush_buf()
101+
for _c in remaining:
102102
self.push(_c)
103103

104104
else:

Lib/test/test_pyrepl/test_eventqueue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_empty(self):
4141
def test_flush_buf(self):
4242
eq = self.make_eventqueue()
4343
eq.buf.extend(b"test")
44-
self.assertEqual(eq.flush_buf(), b"test")
44+
eq.flush_buf()
4545
self.assertEqual(eq.buf, bytearray())
4646

4747
def test_insert(self):

0 commit comments

Comments
 (0)