GNU bug report logs -
#24110
[PATCH] Fix python.el completion with IPython 5.0 and python 2
Previous Next
Reported by: James Porter <james <at> jamesporter.me>
Date: Sat, 30 Jul 2016 01:18:02 UTC
Severity: normal
Tags: patch
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
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)
This bug report was last modified 8 years and 38 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.