Skip to content

test: Remove unused try-block in assert_debug_log - #16804

Merged
laanwj merged 1 commit into
bitcoin:masterfrom
maflcko:1909-testFix
Sep 5, 2019
Merged

laanwj merged 1 commit into
bitcoin:masterfrom
maflcko:1909-testFix

Conversation

@maflcko

@maflcko maflcko commented Sep 4, 2019

Copy link
Copy Markdown
Member

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.

@ryanofsky ryanofsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@DrahtBot

DrahtBot commented Sep 4, 2019

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16673 (Relog configuration args on debug.log rotation by LarryRuane)
  • #16115 (On bitcoind startup, write config args to debug.log by LarryRuane)

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.

@maflcko

maflcko commented Sep 4, 2019

Copy link
Copy Markdown
Member Author

I think the try block was fine and even potentially useful, but the return statement was wrong

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.

@ryanofsky

Copy link
Copy Markdown
Contributor

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 return in a final block if you don't want to ignore exceptions.

@maflcko maflcko changed the title test: Remove incorrect and unused try-block in assert_debug_log test: Remove unused try-block in assert_debug_log Sep 5, 2019
@maflcko

maflcko commented Sep 5, 2019

Copy link
Copy Markdown
Member Author

Renamed GitHub title

@laanwj

laanwj commented Sep 5, 2019

Copy link
Copy Markdown
Member

ACK fae91a0

laanwj added a commit that referenced this pull request Sep 5, 2019
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
@laanwj
laanwj merged commit fae91a0 into bitcoin:master Sep 5, 2019
@maflcko
maflcko deleted the 1909-testFix branch September 5, 2019 17:29
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 2, 2020
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
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Nov 25, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants