Skip to content

Commit 4177e0f

Browse files
authored
Merge pull request #664 from python-cmd2/pointer_bug
Fixed issue where pointer to bytearray was being returned instead of copied bytes
2 parents f5c904c + 1f08873 commit 4177e0f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cmd2/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def getvalue(self) -> str:
325325

326326
def getbytes(self) -> bytes:
327327
"""Get the internal contents as bytes"""
328-
return self.buffer.byte_buf
328+
return bytes(self.buffer.byte_buf)
329329

330330
def read(self) -> str:
331331
"""Read from the internal contents as a str and then clear them out"""
@@ -341,7 +341,7 @@ def readbytes(self) -> bytes:
341341

342342
def clear(self) -> None:
343343
"""Clear the internal contents"""
344-
self.buffer.byte_buf = bytearray()
344+
self.buffer.byte_buf.clear()
345345

346346
def isatty(self) -> bool:
347347
"""StdSim only considered an interactive stream if `echo` is True and `inner_stream` is a tty."""

0 commit comments

Comments
 (0)