cool-RR / PySnooper

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

Minor bug in nesting #180

Open iory opened 4 years ago

iory commented 4 years ago

There is a minor bug at the nesting case. Following is the example.

import time
import pysnooper

snoop = pysnooper.snoop()

def test():
    with snoop:
        a = 10
        with snoop:
            time.sleep(1.0)
        a = 20
        time.sleep(1.0)

test()

The output is the following.

Source path:... <ipython-input-2-9ee7fdb55b80>
22:57:41.232785 line        11         a = 10
New var:....... a = 10
22:57:41.232850 line        12         with snoop:
22:57:41.232936 line        13             time.sleep(1.0)

The debug outputs of the a = 20 and time.sleep(1.0) are vanished. I don't think we'll use it like this, but I'll report it.