Subject: Re: bug#24401: python-shell-completion-native-try returns incorrect results with python 3.5.2

From: Clément Pit--Claudel <[email-masked]>
Date: Sat, 29 Oct 2016 10:12:54 -0400

On 2016-09-10 00:00, Clément Pit--Claudel wrote:
> On 2016-09-09 19:30, Noam Postavsky wrote:
>> On Fri, Sep 9, 2016 at 7:07 PM, Clément Pit--Claudel 
>> <[email-masked]> wrote:
>>> Hi all,
>>>
>>> Calling ‘run-python’ in ‘emacs -Q’ with ‘python-shell-interpreter’
>>> set to "python3", I get the following warning:
>>>
>>> Warning (python): Your ‘python-shell-interpreter’ doesn’t seem to
>>> support readline, yet ‘python-shell-completion-native’ was t and
>>> "python3" is not part of the
>>> ‘python-shell-completion-native-disabled-interpreters’ list. Native
>>> completions have been disabled locally.
>>>
>>> This warning is specific to Python 3 (it doesn't happen with Python
>>> 2.7). Additionally, the warning is spurious; native completion
>>> works fine.  This whole feature is new in Emacs 25.
>>
>> I'm not familiar enough with Python tooling to say much about this, 
>> but it seems similar (maybe identical) to #22897?
> 
> You're right. Why do I never find these duplicates?
> Does anyone object to the proposed fix?

If no one objects, I'll push the attached patch to master tomorrow (or should it go to emacs-25?)

Clément.
From 9dd2c4867966d39d621d4862957b90dcc39fbdf0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit--Claudel?= <[email-masked]>
Date: Wed, 26 Oct 2016 22:46:28 -0400
Subject: [PATCH] python.el: Fix detection of native completion in Python 3
 (bug #24401)

With Python 3.5, (python-shell-completion-native-get-completions ... "")
would return an empty list, causing python.el to think that native
completion was unavailable.

* lisp/progmodes/python.el (python-shell-completion-native-try): Use "_"
  to check whether native completion is available instead of "".
---
 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..290cdc8 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3318,7 +3318,7 @@ python-shell-completion-native-try
          python-shell-completion-native-try-output-timeout))
     (python-shell-completion-native-get-completions
      (get-buffer-process (current-buffer))
-     nil "")))
+     nil "_")))
 
 (defun python-shell-completion-native-setup ()
   "Try to setup native completion, return non-nil on success."
-- 
2.7.4