spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.21k stars 1.59k forks source link

IndexError when introducing snippets #11782

Open mereshow opened 4 years ago

mereshow commented 4 years ago

Description

What steps will reproduce the problem?

Issue reporter appeared while writing code but no apparent error was observed.

Traceback

  File "/home/alberto/Develop/anaconda3/envs/cv_course/lib/python3.7/site-packages/spyder/plugins/editor/extensions/snippets.py", line 878, in insert_snippet
    self.select_snippet(snippet_number=1)
  File "/home/alberto/Develop/anaconda3/envs/cv_course/lib/python3.7/site-packages/spyder/plugins/editor/extensions/snippets.py", line 782, in select_snippet
    start_line, start_column = node_position[0][0]
IndexError: list index out of range

Versions

Dependencies

atomicwrites >=1.2.0         :  1.3.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
cloudpickle >=0.5.0          :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
IPython >=4.0                :  7.12.0 (OK)
jedi =0.14.1                 :  0.14.1 (OK)
keyring                      :  None (OK)
nbconvert >=4.0              :  5.6.1 (OK)
numpydoc >=0.6.0             :  0.9.2 (OK)
pexpect >=4.4.0              :  4.8.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
psutil >=0.3                 :  5.6.7 (OK)
pygments >=2.0               :  2.5.2 (OK)
pylint >=0.25                :  2.4.4 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.7 (OK)
xdg >=0.26                   :  0.26 (OK)
zmq >=17                     :  18.1.1 (OK)
qdarkstyle >=2.7             :  2.8 (OK)
qtawesome >=0.5.7            :  0.6.1 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
rtree >=0.8.3                :  0.9.3 (OK)
sphinx >=0.6.6               :  2.4.0 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
watchdog                     :  None (OK)
cython >=0.21                :  None (NOK)
matplotlib >=2.0.0           :  3.2.0 (OK)
numpy >=1.7                  :  1.18.1 (OK)
pandas >=0.13.1              :  1.0.1 (OK)
scipy >=0.17.0               :  None (NOK)
sympy >=0.7.3                :  None (NOK)
ccordoba12 commented 4 years ago

Could you post the code you were writing that generated this error? Without it it's not possible for us to understand how to solve this problem.

mereshow commented 4 years ago

I was writing it, not running it, and it was opencv related (I am not sure if this was the exact code, maybe I was also using cv2.cvtColor()):

import cv2

img = cv2.imread('DATA/00-puppy.jpg')
cv2.imshow('image', img)

while True:
    if cv2.waitKey(1) & 0xFF == 27:
          break

cv2.destroyAllWindows()
goanpeca commented 4 years ago

@andfoy, any ideas here :-) ?

andfoy commented 3 years ago

Sorry for the late reply, I was able to reproduce this one with the following snippet (when pressing Tab on stop)

import numpy as np

np.arange([stop],)