satpy
satpy copied to clipboard
Fix bz2 unzip function errors
The bz2 unzip function in readers/utils.py
doesn't close the BZ2 file handler, which on some platforms leads to permission errors when os.remove
tries to delete the unclosed files.
This PR wraps the BZ2 handler in a with closing()
statement to prevent this error.
Maybe related to this https://github.com/pytroll/satpy/issues/2183 ?
Codecov Report
Merging #2193 (4f01ae7) into main (0c2b965) will decrease coverage by
0.00%
. The diff coverage is85.96%
.
@@ Coverage Diff @@
## main #2193 +/- ##
==========================================
- Coverage 94.19% 94.19% -0.01%
==========================================
Files 295 295
Lines 45393 45396 +3
==========================================
+ Hits 42760 42761 +1
- Misses 2633 2635 +2
Flag | Coverage Δ | |
---|---|---|
behaviourtests | 4.66% <0.00%> (-0.01%) |
:arrow_down: |
unittests | 94.84% <85.96%> (-0.01%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
satpy/readers/utils.py | 91.95% <45.45%> (ø) |
|
satpy/tests/reader_tests/test_utils.py | 99.25% <95.65%> (-0.75%) |
:arrow_down: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Coverage decreased (-0.004%) to 94.792% when pulling 4f01ae7cfdf8f3c5b1d3ecda5df8a00a1f1e8dee on simonrp84:fix_bz2_unzip into 0c2b9650e48867fbfb6292102400e3d5007bf74a on pytroll:main.
Looks good, do you think the block above could also drop the closing
or would the raising in the except block be a problem?
@mraspaud I think it should be OK to remove that closing
but that's not my code originally so I'm not 100% sure what the original purpose was. I'll remove it as the tests pass OK for this.
I think there has been quite some work merged for this already, so I'm closing this PR for now. Feel free to reopen if it turns out that problem isn't solved.