Coder Social home page Coder Social logo

Comments (9)

alexmojaki avatar alexmojaki commented on June 2, 2024 1

It make things easy to write a log analyser

It sounds like you might prefer using something like https://github.com/ionelmc/python-hunter. Or just writing your own function for sys.settrace.

from pysnooper.

cool-RR avatar cool-RR commented on June 2, 2024

Which versions of PySnooper and Python? And what OS?

from pysnooper.

yantaozhao avatar yantaozhao commented on June 2, 2024

python 3.10, PySnooper 1.2.0, all platforms

from pysnooper.

cool-RR avatar cool-RR commented on June 2, 2024

Ah, it's possible that I have just caused this bug with this most recent version. I'll look into it.

from pysnooper.

cool-RR avatar cool-RR commented on June 2, 2024

If you're interested in writing a failing test case, that'll be helpful.

from pysnooper.

yantaozhao avatar yantaozhao commented on June 2, 2024

commit a PR to fix this issue.

from pysnooper.

cool-RR avatar cool-RR commented on June 2, 2024

Can you explain why there should be a return line when an exception is raised? Can you explain what practical problem it causes that this line doesn't exist?

from pysnooper.

yantaozhao avatar yantaozhao commented on June 2, 2024

Can you explain why there should be a return line when an exception is raised?

No matter exception raised or not, all return event should be recorded because it really happened.
Additionally it make things easy to write a log analyser as the call-return pairs are balanced.

Can you explain what practical problem it causes that this line doesn't exist?

For log readable, consider below example:

import pysnooper


def bar(a, b):
    return a + b


def baz():
    try:
        x = 'hi' + 1  # exception here!
        return 1
    except:
        raise
    finally:  # <-do something and output
        a=1
        b=2
        c=a+b
        foo()
    return -1


def foo():
    r = bar(2, 3)
    print(r)
    return [8]


@pysnooper.snoop(depth=9, normalize=True)
def main():
    try:
        baz()
    except:
        pass


main()

image

if return 18 was not recorded, athough it can, but will spend more time to find that the code ran to and returned from line 18.

from pysnooper.

cool-RR avatar cool-RR commented on June 2, 2024

@yantaozhao Sorry, I'm not seeing the practical usage here. It actually sounds misleading to write "return" when a function exited because of an exception rather than returned a value. I'm not sure what your use case is, but it sounds like it's a very niche use case that's not worth compromising for.

from pysnooper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.