-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SysCaptureBinary: decode in writeorg #6880
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix crash with captured output when using the :fixture:`capsysbinary fixture <capsysbinary>`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -681,7 +681,8 @@ def resume(self): | |
setattr(sys, self.name, self.tmpfile) | ||
self._state = "resumed" | ||
|
||
def writeorg(self, data): | ||
def writeorg(self, data: str) -> None: | ||
data = data.decode(self._old.encoding) | ||
self._old.write(data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe write to |
||
self._old.flush() | ||
|
||
|
@@ -695,6 +696,10 @@ def snap(self): | |
self.tmpfile.truncate() | ||
return res | ||
|
||
def writeorg(self, data: str) -> None: | ||
self._old.write(data) | ||
self._old.flush() | ||
|
||
|
||
class TeeSysCapture(SysCapture): | ||
def __init__(self, fd, tmpfile=None): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be
bytes
. It seems like thedata = data....
confused mypy so it didn't catch it.