bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24110: [PATCH] Fix python.el completion with IPython 5.0 and python


From: James Porter
Subject: bug#24110: [PATCH] Fix python.el completion with IPython 5.0 and python 2
Date: Fri, 29 Jul 2016 21:01:16 -0400

In version 5.0 of IPython, which was recently released, the
IPCompleter.all_completions method changed slightly when running under
Python 2--it returns a unicode object rather than a str object. This
causes python.el completion to fail, since it uses this function and
the string Emacs gets back from the Python subprocess is e.g. if the
two valid completions are random and range: `u'random;range'` as
opposed to `'random;range'`, which isn't parsed correctly on the Emacs
side due to the spurious leading `u`. The below patch fixes this issue
by wrapping the string sent to Python for evaluation in a call to
`print`, which avoids printing the `u` when the return value is a
unicode object.

Cheers,
James Porter


* lisp/progmodes/python.el(python-shell-completion-string-code): Wrap
in a call to print to correctly handle the case that the return value
is unicode.

---
 lisp/progmodes/python.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ad69f87..f87052f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3258,7 +3258,7 @@ def __PYTHON_EL_get_completions(text):
   :group 'python)

 (defcustom python-shell-completion-string-code
-  "';'.join(__PYTHON_EL_get_completions('''%s'''))"
+  "print(';'.join(__PYTHON_EL_get_completions('''%s''')))"
   "Python code used to get a string of completions separated by semicolons.
 The string passed to the function is the current python name or
 the full statement in the case of imports."
--
2.6.4 (Apple Git-63)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]