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

Incorrect "Call ended by exception" when using finally blocks #134

Open
alexmojaki opened this issue Jul 3, 2019 · 1 comment
Open

Incorrect "Call ended by exception" when using finally blocks #134

alexmojaki opened this issue Jul 3, 2019 · 1 comment

Comments

@alexmojaki
Copy link
Collaborator

The method for testing if a call ended with an exception is not quite accurate. Here's an example:

import pysnooper

@pysnooper.snoop()
def foo():
    try:
        return None
    finally:
        pass

foo()
22:07:00.954045 call         5 def foo():
22:07:00.954555 line         6     try:
22:07:00.954637 line         7         return None
22:07:00.956724 line         9         pass
Call ended by exception

I don't know of any easy reliable way to tell the difference between returning None and raising an exception inside a try/finally. For now I keep track of whether a call has raised an exception at all, and if it hasn't (like above) I know it's definitely a return. If it has, I simply don't know: https://github.com/alexmojaki/snoop/blob/a93925011365099abb8f77315060093a1efed29b/snoop/formatting.py#L271

On a related note, I started a discussion about truncating exception messages here which you may want to follow.

@cool-RR
Copy link
Owner

cool-RR commented Jul 4, 2019

Thanks for reporting this. Right now I think it's a small enough issue that I can ignore it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants