Repository navigation
test: Remove unused try-block in assert_debug_log - #16804
Conversation
ryanofsky
left a comment
There was a problem hiding this comment.
utACK fae91a0. I didn't know returning inside a finally block would cancel pending exceptions or return values, but I guess this makes sense and is a good thing to be aware of.
I'd maybe rephrase "Remove incorrect and unused try-block". I think the try block was fine and even potentially useful, but the return statement was wrong. It should be fine to remove the try block, though. Only difference should be that if a test is expecting an exception and a log message it will now need to catch the exception inside the assert_debug_log block instead of being able to catch it outside.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
I think either of them is fine on their own, but in combination, at least one of them is incorrect. Though, I am happy to change to something else, if you have any suggestions. |
|
It's fine, I only meant to suggest changing "Remove incorrect and unused try-block" to "Remove unused try-block." AFAICT using a try block is correct and appropriate here, but nothing requires a try block right now, so it's ok to simplify and remove. But returning in a final block ignores exceptions, so it's definitely a bug to use a |
|
Renamed GitHub title |
|
ACK fae91a0 |
fae91a0 test: Remove incorrect and unused try-block in assert_debug_log (MarcoFalke) Pull request description: This try block has accidentally been added by me in fa3e9f7. It was unused all the time, but commit 6011c9d added a `return` in the finally block, muting all exceptions. This can be tested by adding an `assert False` after any `with ...assert_debug_log...:` line. ACKs for top commit: laanwj: ACK fae91a0 ryanofsky: utACK fae91a0. I didn't know returning inside a `finally` block would cancel pending exceptions or return values, but I guess this makes sense and is a good thing to be aware of. Tree-SHA512: 47ed0165062060e9af055a3e92f1a529cd41d00476bfad64e3cd141ae084d22f926a343bb1257717e164e15459a59ab66aed198c95d18bf780d8cb0b76aa3298
Summary: This is a backport of Core [[bitcoin/bitcoin#16804 | PR16804]] Test Plan: ninja all check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D5939
fae91a0 test: Remove incorrect and unused try-block in assert_debug_log (MarcoFalke) Pull request description: This try block has accidentally been added by me in fa3e9f7. It was unused all the time, but commit 6011c9d added a `return` in the finally block, muting all exceptions. This can be tested by adding an `assert False` after any `with ...assert_debug_log...:` line. ACKs for top commit: laanwj: ACK fae91a0 ryanofsky: utACK fae91a0. I didn't know returning inside a `finally` block would cancel pending exceptions or return values, but I guess this makes sense and is a good thing to be aware of. Tree-SHA512: 47ed0165062060e9af055a3e92f1a529cd41d00476bfad64e3cd141ae084d22f926a343bb1257717e164e15459a59ab66aed198c95d18bf780d8cb0b76aa3298
This try block has accidentally been added by me in fa3e9f7.
It was unused all the time, but commit 6011c9d added a
returnin the finally block, muting all exceptions.This can be tested by adding an
assert Falseafter anywith ...assert_debug_log...:line.