From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: James Porter Newsgroups: gmane.emacs.bugs Subject: bug#24110: [PATCH] Fix python.el completion with IPython 5.0 and python 2 Date: Fri, 29 Jul 2016 21:01:16 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1469841514 32310 80.91.229.3 (30 Jul 2016 01:18:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 30 Jul 2016 01:18:34 +0000 (UTC) To: 24110@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 30 03:18:22 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bTIuy-0003wr-RG for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Jul 2016 03:18:21 +0200 Original-Received: from localhost ([::1]:33795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTIus-0006CO-RX for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Jul 2016 21:18:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTIun-0006Be-0b for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2016 21:18:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bTIug-0004sV-UP for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2016 21:18:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTIug-0004sR-Rh for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2016 21:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bTIug-0002Yk-Bs for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2016 21:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: James Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Jul 2016 01:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24110 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14698414239772 (code B ref -1); Sat, 30 Jul 2016 01:18:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Jul 2016 01:17:03 +0000 Original-Received: from localhost ([127.0.0.1]:51039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bTIti-0002XY-PK for submit@debbugs.gnu.org; Fri, 29 Jul 2016 21:17:02 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bTIei-0002C2-TT for submit@debbugs.gnu.org; Fri, 29 Jul 2016 21:01:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bTIec-0001ON-KL for submit@debbugs.gnu.org; Fri, 29 Jul 2016 21:01:27 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:57429) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTIec-0001OD-Hw for submit@debbugs.gnu.org; Fri, 29 Jul 2016 21:01:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTIeY-0002Vh-7c for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2016 21:01:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bTIeU-0001Nt-5r for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2016 21:01:21 -0400 Original-Received: from mail-vk0-f66.google.com ([209.85.213.66]:35001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTIeU-0001Np-1P for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2016 21:01:18 -0400 Original-Received: by mail-vk0-f66.google.com with SMTP id x130so3758551vkc.2 for ; Fri, 29 Jul 2016 18:01:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Ys8CadsptRRVX3cvzJc/fokTqUqhUx0NLJotULDxyDk=; b=Z2ZqTLFxVTrRmWdl0dpDJdT65PKu+sq5Tb8r7Fh1j32qOX/oQsUYdpN6/Y92dQcxuZ rRRfirWhO78vxVqP8k5o8uCPTSEDfJ9015piGnLlWUNHhmy4HywFS4nHheVymx6PiRU9 U1CUFy/XIg5B9H4khO9vPt3QgGB2WQXKw9PhTzKFKO9iGwTO/fw7eaolFGWoMnw4EJap 0wb6VRcgkM32LEHjd1PWo9m3XjtPTpW/GwoufHJLC97c6sR9Ip3uZTsPayDOB32pKqnW 7XouM3aEjX8x97EP3IovkTN9hhJvA3r0zYXm7dl+h+duSfCb8UDThGraGef5SYRB/wPK A1+g== X-Gm-Message-State: AEkoouvB82kLXlTNBdUGoYq2da8/VeGCmWK6bowiCHQyKH61T3QxwwBWKXSON6fqqQZESg== X-Received: by 10.31.159.67 with SMTP id i64mr18378485vke.104.1469840477104; Fri, 29 Jul 2016 18:01:17 -0700 (PDT) Original-Received: from mail-vk0-f42.google.com (mail-vk0-f42.google.com. [209.85.213.42]) by smtp.gmail.com with ESMTPSA id 80sm3162574uar.8.2016.07.29.18.01.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jul 2016 18:01:17 -0700 (PDT) Original-Received: by mail-vk0-f42.google.com with SMTP id s189so65530702vkh.1 for ; Fri, 29 Jul 2016 18:01:16 -0700 (PDT) X-Received: by 10.31.53.75 with SMTP id c72mr20187323vka.62.1469840476694; Fri, 29 Jul 2016 18:01:16 -0700 (PDT) Original-Received: by 10.31.83.68 with HTTP; Fri, 29 Jul 2016 18:01:16 -0700 (PDT) X-Gmail-Original-Message-ID: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Fri, 29 Jul 2016 21:17:02 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121702 Archived-At: 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)