Skip to content
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

pylint 3.2.2 fixes: initialize gdb_sandbox and fix UnboundLocalError in add_kernel_crash_info #339

Merged
merged 2 commits into from
Jun 11, 2024

Conversation

bdrung
Copy link
Collaborator

@bdrung bdrung commented Jun 10, 2024

pylint 3.2.2 complains:

************* Module apport-retrace
bin/apport-retrace:515:27: E0601: Using variable 'gdb_sandbox' before assignment (used-before-assignment)
************* Module apport.report
apport/report.py:878:71: E0606: Possibly using variable 'core' before assignment (possibly-used-before-assignment)

If options.gdb_sandbox evaluates to True, the architecture is the system architecture, and sandbox evaluates to False, gdb_sandbox will not be set.

The case in apport/report.py can be hit by analyzing a local kernel crash report with apport-retrace. load_report in apport-retrace loads the report with binary="compressed". This leads to VmCore being an instance of CompressedValue which does not have a find method.

Use the high-level interface tempfile.NamedTemporaryFile instead of tempfile.mkstemp and always write the VmCore content. Add support for writing CompressedValue. Add unit tests to (hopefully) cover all cases. Note: add_kernel_crash_info is only called by apport-retrace.

pylint 3.2.2 complains:

```
bin/apport-retrace:515:15: E0601: Using variable 'gdb_sandbox' before assignment (used-before-assignment)
```

If `options.gdb_sandbox` evaluates to True, the architecture is the
system architecture, and `sandbox` evaluates to False, `gdb_sandbox`
will not be set.
@bdrung bdrung requested a review from schopin-pro June 10, 2024 10:13
Copy link

codecov bot commented Jun 10, 2024

Codecov Report

Attention: Patch coverage is 97.67442% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.53%. Comparing base (52560e6) to head (b635c45).

Files Patch % Lines
apport/report.py 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #339      +/-   ##
==========================================
+ Coverage   82.40%   82.53%   +0.12%     
==========================================
  Files          94       94              
  Lines       19334    19366      +32     
  Branches     3113     3114       +1     
==========================================
+ Hits        15932    15983      +51     
+ Misses       2906     2886      -20     
- Partials      496      497       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pylint 3.2.2 complains:

```
apport/report.py:878:71: E0606: Possibly using variable 'core' before assignment (possibly-used-before-assignment)
```

This case can be hit by analyzing a local kernel crash report with
apport-retrace. `load_report` in `apport-retrace` loads the report with
`binary="compressed"`. This leads to `VmCore` being an instance of
`CompressedValue` which does not have a `find` method.

Use the high-level interface `tempfile.NamedTemporaryFile` instead of
`tempfile.mkstemp` and always write the `VmCore` content. Add support
for writing `CompressedValue`. Add unit tests to (hopefully) cover all
cases. Note: `add_kernel_crash_info` is only called by `apport-retrace`.

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
@schopin-pro schopin-pro merged commit f2b6a46 into canonical:main Jun 11, 2024
21 checks passed
@bdrung bdrung deleted the pylint-3.2.2 branch June 11, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants