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

simple for loop example fails #36

Closed
ghost opened this issue Apr 24, 2019 · 3 comments
Closed

simple for loop example fails #36

ghost opened this issue Apr 24, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Apr 24, 2019

  @pysnooper.snoop()                                                                                                                            
  def hello():                                                                                                                                  
      for i in range(10):                                                                                                                       
          print(i)                                                                                                                              

In [10]: ---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
in
----> 1 import codecs, os;__pyfile = codecs.open('''/tmp/pybsaClo''', encoding='''utf-8''');__code = __pyfile.read().encode('''utf-8''');__pyfile$

/export/zxf/workspace/tmp/testsnoop.py in
22
23
---> 24 hello()

</home/zxf/anaconda3/lib/python3.6/site-packages/decorator.py:decorator-gen-152> in hello()

~/anaconda3/lib/python3.6/site-packages/PySnooper-0.0.11-py3.6.egg/pysnooper/pysnooper.py in decorate(function, *args, **kwargs)
70 write=write, variables=variables,
71 depth=depth, prefix=prefix):
---> 72 return function(*args, **kwargs)
73
74 return decorate

/export/zxf/workspace/tmp/testsnoop.py in hello()
15
16
---> 17 @pysnooper.snoop()
18 def hello():
19 for i in range(10):

~/anaconda3/lib/python3.6/site-packages/PySnooper-0.0.11-py3.6.egg/pysnooper/tracer.py in trace(self, frame, event, arg)
182
183 now_string = datetime_module.datetime.now().time().isoformat()
--> 184 source_line = get_source_from_frame(frame)[frame.f_lineno - 1]
185 self.write('{indent}{now_string} {event:9} '
186 '{frame.f_lineno:4} {source_line}'.format(**locals()))

IndexError: list index out of range

@ghost
Copy link
Author

ghost commented Apr 24, 2019

But if I remove the decrator, it runs ok.

@cool-RR
Copy link
Owner

cool-RR commented Apr 24, 2019

Duplicate of #16

@cool-RR cool-RR marked this as a duplicate of #16 Apr 24, 2019
@cool-RR cool-RR closed this as completed Apr 24, 2019
@cool-RR
Copy link
Owner

cool-RR commented Apr 24, 2019

@iecaser PySnooper now works in Jupyter and IPython :)

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

1 participant