Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix AttributeError: 'NoneType' object has no attribute 'write'
Apport can fail with: ``` Traceback (most recent call last): File "/usr/share/apport/apport", line 531, in <module> options = parse_arguments() File "/usr/share/apport/apport", line 463, in parse_arguments parser.print_usage() File "/usr/lib/python3.9/argparse.py", line 2557, in print_usage self._print_message(self.format_usage(), file) File "/usr/lib/python3.9/argparse.py", line 2568, in _print_message file.write(message) AttributeError: 'NoneType' object has no attribute 'write' ``` The kernel calls apport with no stdout and stderr file descriptors set. Therefore `sys.stdout` and `sys.stderr` are `None`. So initialize the error log before parsing the command line arguments. Also improve the error message when no process ID (PID) is provided. Bug: https://launchpad.net/bugs/1979211 Fixes: c320e91 ("Switch to using non-positional arguments") Signed-off-by: Benjamin Drung <bdrung@ubuntu.com>
- Loading branch information