-
Notifications
You must be signed in to change notification settings - Fork 280
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
Exception in jedi crashes ptpython #47
Comments
Hi @pgy , Thanks for reporting. |
So, the following patch prevents ptpython from crashing. There is still a bug in Jedi that prevents us from getting the right index when passing after the diff --git a/ptpython/layout.py b/ptpython/layout.py
index 5e13060..86037ed 100644
--- a/ptpython/layout.py
+++ b/ptpython/layout.py
@@ -113,12 +113,14 @@ class SignatureToolbar(Window):
append((Signature.Operator, '('))
for i, p in enumerate(sig.params):
+ # p is None when we hit the '*' in the signature.
+ description = p.description if p else '*'
+
+ try:
+ sig_index = sig.index
+ except AttributeError:
+ sig_index = 0
+ if i == sig_index:
- if i == sig.index:
# Note: we use `_Param.description` instead of
# `_Param.name`, that way we also get the '*' before args.
- append((Signature.CurrentName, str(p.description)))
+ append((Signature.CurrentName, str(description)))
else:
- append((Signature, str(p.description)))
+ append((Signature, str(description or '--')))
append((Signature.Operator, ', '))
if sig.params:
diff --git a/ptpython/python_input.py b/ptpython/python_input.py
index f2167be..62939db 100644
--- a/ptpython/python_input.py
+++ b/ptpython/python_input.py
@@ -406,6 +406,13 @@ class PythonInput(object):
else:
signatures = []
+ if signatures:
+ try:
+ # Access the params attribute just once. Next time it doesn't give AttributeError.
+ signatures[0].params
+ except AttributeError:
+ pass
+ signatures[0].params
+
self._get_signatures_thread_running = False
# Set signatures and redraw if the text didn't change in the |
@jonathanslenders The |
The following crashes ptpython, it exists (with status 1) immediately after entering the '=' sign.
The text was updated successfully, but these errors were encountered: