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
apport-unpack: fix reading from stdin #255
Conversation
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
apport-unpack opens the report file two times. Refactor the code to move the duplicate file opening into `open_report`. Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Calling `report.extract_keys` is only needed if there are binary keys that need extraction. Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Reading a report from stdin fails: ``` Traceback (most recent call last): File "bin/apport-unpack", line 91, in <module> main() File "bin/apport-unpack", line 70, in main report.load(report_file, binary=False) File "problem_report.py", line 155, in load self._assert_bin_mode(file) File "problem_report.py", line 792, in _assert_bin_mode assert not hasattr(file, "encoding"), "file stream must be in binary mode" AssertionError: file stream must be in binary mode ``` This failure has been found by mypy after adding type hints to `ProblemReport.load`. Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #255 +/- ##
==========================================
+ Coverage 83.80% 83.84% +0.03%
==========================================
Files 93 93
Lines 18837 18851 +14
==========================================
+ Hits 15787 15805 +18
+ Misses 3050 3046 -4 ☔ View full report in Codecov by Sentry. |
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.
LGTM, but I'm really confused, what's the original bug exactly? It lookt to me that the previous code was always giving in sys.stdin
, which is a TextIOWrapper so not binary.
That the crash with apport 2.27.0:
|
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.
LGTM, there's a wider issue but it's out of scope.
Reading a report from stdin fails:
This failure has been found by mypy after adding type hints to
ProblemReport.load
.