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

IndexError when getting help of an object #6314

Closed
smtodd opened this issue Jan 28, 2018 · 3 comments
Closed

IndexError when getting help of an object #6314

smtodd opened this issue Jan 28, 2018 · 3 comments

Comments

@smtodd
Copy link

smtodd commented Jan 28, 2018

Description

What steps will reproduce the problem?

  1. Create a function named "print_file" in the text editor. The contents or arguments of the function have no effect on the error. The function name is the critical part. Changing the function name prevents this error. Using: Windows 10, Python 3.6 Anaconda install. Anaconda 3 64-bit
  2. Run the cell to load the function into the IPython console.
  3. Enter the function in the console. This error is generated by typing the open parentheses "("

What is the expected output? What do you see instead?
Because changing the function itself does not affect this error, there is no specific expected output. Multiple functions were tried. This causes the Spyder error popup window to appear. Clicking "OK" on the window closes it and the function can be run normally in the IPython console afterwards.

Please provide any additional information below

File "C:\Users\steve\Anaconda3\lib\site-packages\spyder\plugins\help.py", line 92, in validate
valid = self.is_valid(qstr)
File "C:\Users\steve\Anaconda3\lib\site-packages\spyder\plugins\help.py", line 74, in is_valid
return shell.is_defined(objtxt, force_import=True)
File "C:\Users\steve\Anaconda3\lib\site-packages\spyder\widgets\internalshell.py", line 467, in is_defined
return self.interpreter.is_defined(objtxt, force_import)
File "C:\Users\steve\Anaconda3\lib\site-packages\spyder\interpreter.py", line 312, in is_defined
namespace=self.locals)
File "C:\Users\steve\Anaconda3\lib\site-packages\spyder\utils\dochelpers.py", line 305, in isdefined
module = import(base, globals(), namespace)
File "C:\Users\steve\Documents\Online Classes\Coursera Python Programming Introduction\print_file.py", line 6, in
filename = sys.argv[1]
IndexError: list index out of range

Version and main components

  • Spyder Version: 3.2.4
  • Python Version: 3.6.3
  • Qt Versions: 5.6.2, PyQt5 5.6 on Windows

Dependencies

pyflakes >=0.6.0 :  1.6.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.20.3 (OK)
numpy >=1.7      :  1.13.3 (OK)
sphinx >=0.6.6   :  1.6.3 (OK)
rope >=0.9.4     :  0.10.5 (OK)
jedi >=0.9.0     :  0.10.2 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
sympy >=0.7.3    :  1.1.1 (OK)
cython >=0.21    :  0.26.1 (OK)
qtconsole >=4.2.0:  4.3.1 (OK)
IPython >=4.0    :  6.1.0 (OK)
pylint >=0.25    :  1.7.4 (OK)

@CAM-Gerlach
Copy link
Member

Thanks for reporting. I was unable to reproduce this error in Spyder 3.2.6 on Windows 8.1 Pro x64 with Python 3.6.4 x64 and the same versions of Qt, IPython, qtconsole, rope, jedi, and sphix as you. Please try updating Spyder and Python, and seeing if the error reoccurs. For reference, I stuck the function

def print_file(to_print):
    print("Printed: " + str(to_print))

in a cell, and then tried running

print_file("test 2")

in both the console and the editor, and everything worked fine.

@ccordoba12
Copy link
Member

@dalthviz, please catch IndexError around module = __import__(base, globals(), namespace) in utils/dochelpers.py.

@ccordoba12
Copy link
Member

Or better still, simply catch any error at point to avoid more errors like this one in the future.

@ccordoba12 ccordoba12 changed the title Cannot name function print_file IndexError when getting help of an object Jan 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants