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

crash error #12777

Closed
sataliulan opened this issue Jan 20, 2021 · 6 comments
Closed

crash error #12777

sataliulan opened this issue Jan 20, 2021 · 6 comments
Milestone

Comments

@sataliulan
Copy link

sataliulan commented Jan 20, 2021

In [3]: nn.relu
Traceback (most recent call last):
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/ptutils.py", line 113, in get_completions
    yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/ptutils.py", line 129, in _get_completions
    for c in completions:
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py", line 438, in _deduplicate_completions
    completions = list(completions)
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py", line 1818, in completions
    for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py", line 1862, in _completions
    full_text=full_text, cursor_line=cursor_line, cursor_pos=cursor_column)
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py", line 2030, in _complete
    cursor_pos, cursor_line, full_text)
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py", line 1374, in _jedi_matches
    text[:offset], namespaces, column=cursor_column, line=cursor_line + 1)
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/jedi/api/__init__.py", line 726, in __init__
    project=Project(Path.cwd()), **kwds)
TypeError: __init__() got an unexpected keyword argument 'column'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hcl/miniconda3/envs/pytorch/bin/ipython", line 8, in <module>
    sys.exit(start_ipython())
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/__init__.py", line 126, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/traitlets/config/application.py", line 845, in launch_instance
    app.start()
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/ipapp.py", line 356, in start
    self.shell.mainloop()
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 564, in mainloop
    self.interact()
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 547, in interact
    code = self.prompt_for_code()
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 475, in prompt_for_code
    **self._extra_prompt_options())
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1013, in prompt
    return self.app.run(set_exception_handler=set_exception_handler)
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 817, in run
    self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 783, in run_async
    return await _run_async2()
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 771, in _run_async2
    await self.cancel_and_wait_for_background_tasks()
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 872, in cancel_and_wait_for_background_tasks
    await task
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/buffer.py", line 1854, in new_coroutine
    await coroutine(*a, **kw)
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/buffer.py", line 1684, in async_completer
    document, complete_event
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/completion/base.py", line 270, in get_completions_async
    document, complete_event
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/completion/base.py", line 196, in get_completions_async
    for item in self.get_completions(document, complete_event):
  File "/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/ptutils.py", line 116, in get_completions
    exc_type, exc_value, exc_tb = sys.exc_info()
NameError: name 'sys' is not defined

If you suspect this is an IPython 7.19.0 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True
@ahmetkotan
Copy link

ahmetkotan commented Jan 20, 2021

This issue's root not due to ipython. Actually coming from jedi package. But ipython also has an error related to this. sys module not imported in get_completions exception.

@ahmetkotan
Copy link

sys and traceback modules added 7 months ago but not updated in pypi. Because of this, this error not related to ipython. It's error in jedi.

@lociii
Copy link

lociii commented Jan 20, 2021

Could you please give some more detailed info on why this is an issue in jedi?
Latest ipython release on PyPI is 7.19.0 which contains the missing import that is - as you already noted - fixed on master but not released.
https://github.com/ipython/ipython/blob/7.19.0/IPython/terminal/ptutils.py

No import of sys

import pygments.lexers as pygments_lexers
import os
_completion_sentinel = object()

Usage of sys

exc_type, exc_value, exc_tb = sys.exc_info()

@mmesiti
Copy link

mmesiti commented Jan 20, 2021

Reading the traceback:

  1. The sys and traceback imports are missing in IPython/terminal/ptutils.py, and this is the problem that causes the Ipython crash;
  2. In jedi/api/__init__.py, it complains that the "column" argument is passed to Script.__init__, which does not accept such argument;
  3. This error comes from IPython/core/completer.py, where at line 1373 a new jedi.Interpreter is created, passing a "column" argument to it, which chokes it.

The way to create a Script object has changed between jedi 0.17 and jedi 0.18:
In 0.17:

     def __init__(self, code=None, line=None, column=None, path=None,                                    
                 encoding=None, sys_path=None, environment=None,                                               
                 project=None, source=None):

in 0.18:

    def __init__(self, code=None, *, path=None, environment=None, project=None):

If you install jedi 0.17 instead of jedi 0.18 the current version of ipython should work.
This worked for me:

pip uninstall jedi
pip install jedi==0.17.2

@ebc-conscia
Copy link

ebc-conscia commented Jan 28, 2021

Reading the traceback:

  1. The sys and traceback imports are missing in IPython/terminal/ptutils.py, and this is the problem that causes the Ipython crash;
  2. In jedi/api/__init__.py, it complains that the "column" argument is passed to Script.__init__, which does not accept such argument;
  3. This error comes from IPython/core/completer.py, where at line 1373 a new jedi.Interpreter is created, passing a "column" argument to it, which chokes it.

The way to create a Script object has changed between jedi 0.17 and jedi 0.18:
In 0.17:

     def __init__(self, code=None, line=None, column=None, path=None,                                    
                 encoding=None, sys_path=None, environment=None,                                               
                 project=None, source=None):

in 0.18:

    def __init__(self, code=None, *, path=None, environment=None, project=None):

If you install jedi 0.17 instead of jedi 0.18 the current version of ipython should work.
This worked for me:

pip uninstall jedi
pip install jedi==0.17.2

as jedi 0.18 introduced a breaking change for something as basic as autocompletion, shouldn't jedi dependency be pinned as a solution?

edit: can see there's already a pull request for this. #12783

@Carreau
Copy link
Member

Carreau commented Jan 30, 2021

#12793 fixes it. IPython master already had the changes.
No, pinning jedi does not work because pip uses a resolver (conda as well), so if I release a new version of IPython that say "jedi < 0.18", the resolver if free to say. "Cool, cool, cool, I'll install jedi=0.18 and don't upgrade IPython".

@Carreau Carreau closed this as completed Jan 30, 2021
@Carreau Carreau added this to the 7.20 milestone Jan 30, 2021
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

6 participants