From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 29 21:17:03 2016 Received: (at submit) by debbugs.gnu.org; 30 Jul 2016 01:17:03 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 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 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 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 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 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) 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) 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) MIME-Version: 1.0 Received: by 10.31.83.68 with HTTP; Fri, 29 Jul 2016 18:01:16 -0700 (PDT) From: James Porter Date: Fri, 29 Jul 2016 21:01:16 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: [PATCH] Fix python.el completion with IPython 5.0 and python 2 To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=UTF-8 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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) From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 03 11:13:44 2017 Received: (at 24110) by debbugs.gnu.org; 3 Jul 2017 15:13:44 +0000 Received: from localhost ([127.0.0.1]:50489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dS32m-0007IU-5Y for submit@debbugs.gnu.org; Mon, 03 Jul 2017 11:13:44 -0400 Received: from mail-io0-f181.google.com ([209.85.223.181]:35822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dS32j-0007I8-Kq; Mon, 03 Jul 2017 11:13:42 -0400 Received: by mail-io0-f181.google.com with SMTP id h134so58345863iof.2; Mon, 03 Jul 2017 08:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=/yd9DHeaTcsO4qnD9X+4TvnR0J+s0kJbtFLuMnNfmRE=; b=CEfDm/F1N1KLQGF8aepr/PEnrwEMwoTb8ztTjXFbiMIqMn7J6WNVJvUpTqWLxK3HA6 Vjz8XAKhBFWEGQbhVNSyzQZTJHSkQexOjTBmtu1Db10dSPPCIPDLlVWUbtt8F7aqZkDu 4Ato3j/9WbkNv4ZW54tUwUiPuHmhUQvVwV063+btGpQYQsrFqd0bCfPtJHTAqzL+YoYp SYouQn6ZUQxeKJ21mXZLHuVuhQC/Rt2i5Ug7Ohoq5/do4/se/qg0fDC9JRecp/sODje0 T3mHH3yDsjtFEWRLqHsvhk88A7tjrIr0dSlayltgmkPQewr6ameGA7oclHOAWSrhNiOD /hAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=/yd9DHeaTcsO4qnD9X+4TvnR0J+s0kJbtFLuMnNfmRE=; b=IWSrGwEUqt65j4SWvZITYIn7d1X01zdFDh71Sc54STagZkT8JTINLZBzBtfU4yadTR hryWv9OSwLOq2ubSd6h7sLlk0hDx46Lg4bFmmSf1epa2aHVoIBq40P84zuEvceEOG3gr 6iS65Kre47XmpzIE3iwI4uh3b2XNIp1hqJHphUGW+Jw53CT+l4YKgP4wscA6vXVIqAGp 77uqi4xFpfWdsmlei7jniQ+fGiLyw/G3uWMkFkKdUSzoupt6FifeDdSj8LjnVfwkDr7c S95ZZdNFLYyufK2AsM4znOjUrVqvksH/1lNNlphZYwWysgBSOQVyZBlIPbGMQe647LUE /HJA== X-Gm-Message-State: AKS2vOybfxvUCrUqfDnTAKSGscSKf8Ef/CocEBV/nhW4Ysu0d/DI/IsS EyTJ03Df8VWMoQiE X-Received: by 10.107.137.152 with SMTP id t24mr36452789ioi.218.1499094815659; Mon, 03 Jul 2017 08:13:35 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id j76sm8523968ioi.14.2017.07.03.08.13.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jul 2017 08:13:34 -0700 (PDT) From: npostavs@users.sourceforge.net To: James Porter Subject: Re: bug#24110: [PATCH] Fix python.el completion with IPython 5.0 and python 2 References: Date: Mon, 03 Jul 2017 11:15:11 -0400 In-Reply-To: (James Porter's message of "Fri, 29 Jul 2016 21:01:16 -0400") Message-ID: <8760f9k0w0.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 24110 Cc: 24110@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) close 24110 quit James Porter writes: > (defcustom python-shell-completion-string-code > - "';'.join(__PYTHON_EL_get_completions('''%s'''))" > + "print(';'.join(__PYTHON_EL_get_completions('''%s''')))" This patch is no longer applicable, in 25.1 there is already a 'print' added by python-shell-completion-get-completions. (defun python-shell-completion-get-completions (process import input) "Do completion at point using PROCESS for IMPORT or INPUT. When IMPORT is non-nil takes precedence over INPUT for completion." (setq input (or import input)) (with-current-buffer (process-buffer process) (let ((completions (python-util-strip-string (python-shell-send-string-no-output (format (concat python-shell-completion-setup-code "\nprint (" python-shell-completion-string-code ")") input) process)))) (when (> (length completions) 2) (split-string completions "^'\\|^\"\\|;\\|'$\\|\"$" t))))) From unknown Sat Sep 06 09:45:44 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 01 Aug 2017 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator