cool-RR / PySnooper

Never use print for debugging again
MIT License
16.34k stars 951 forks source link

Help: trouble with "SOURCE UNAVAILABLE" #164

Closed samhld closed 4 years ago

samhld commented 4 years ago

Overall, this is working for me but instead of getting the line of code that's being evaluated, I'm getting a constant SOURCE UNAVAILABLE message. It looks like this is called from here. Not sure why it's not a "source" though. Can you help? Thanks!

This is happening on a very basic function, say:

@pysnooper.snoop()
def hello(name):
     print(f"Hello, {name}")

Returns:

> hello('sam')
Source path:... <stdin>
Starting var:.. name = 'sam'
17:27:50.065066 call         1 SOURCE IS UNAVAILABLE
17:27:50.065288 line         3 SOURCE IS UNAVAILABLE
Hello, sam
17:27:50.065439 return       3 SOURCE IS UNAVAILABLE
Return value:.. None
cool-RR commented 4 years ago

What's the scenario? Where is your function defined? In a code file, in a shell, and if so what shell?

On Fri, Oct 18, 2019, 03:34 Sam Dillard notifications@github.com wrote:

Overall, this is working for me but instead of getting the line of code that's being evaluated, I'm getting a constant SOURCE UNAVAILABLE message. It looks like this is called from here https://github.com/cool-RR/PySnooper/blob/master/pysnooper/tracer.py#L89. Not sure why it's not a "source" though. Can you help? Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cool-RR/PySnooper/issues/164?email_source=notifications&email_token=AAAN3SSXO3L76CZ7YDFBMJLQPEAB3A5CNFSM4JCBAQW2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HSTQGAA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN3SWEK3LPCTQCCG4VUQ3QPEAB3ANCNFSM4JCBAQWQ .

samhld commented 4 years ago

@cool-RR it's defined in a python3 interactive shell. Sounds like maybe I don't understand what "source" means in this case?

alexmojaki commented 4 years ago

The source code isn't saved anywhere in a regular shell. If you write code that raises an exception you'll see that code doesn't show in the traceback either.

cool-RR commented 4 years ago

@alexmojaki is correct. If you were to suggest to python-ideas to start saving source code on code objects, I would support that suggestion, and that would make this feature possible. I think that they're unlikely to accept it, but let me know if you try.

samhld commented 4 years ago

thanks, guys! Clears that up.