From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#25025: python-shell-calculate-command is wrong Date: Thu, 01 Dec 2016 19:10:50 +0200 Message-ID: <83d1hbpobp.fsf@gnu.org> References: <83polk3qow.fsf@gnu.org> <83inra13r3.fsf@gnu.org> <8337ic29y0.fsf@gnu.org> <87r35wj4b8.fsf@users.sourceforge.net> <83zikkzytf.fsf@gnu.org> <8737i9iz28.fsf@users.sourceforge.net> <1949fc46-fd26-dddb-86b2-ab3478587271@gmail.com> <87wpflhgsf.fsf@users.sourceforge.net> <83a8chq7x6.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1480612503 2450 195.159.176.226 (1 Dec 2016 17:15:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 1 Dec 2016 17:15:03 +0000 (UTC) Cc: 25025@debbugs.gnu.org, clement.pit@gmail.com To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 01 18:14:59 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCUwj-0007zR-8c for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Dec 2016 18:14:57 +0100 Original-Received: from localhost ([::1]:57634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCUwm-0006jT-Tp for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Dec 2016 12:15:00 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCUt0-0003PF-4h for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2016 12:11:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCUsw-00007a-TC for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2016 12:11:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33543) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cCUsw-00007S-Q7 for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2016 12:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cCUsw-0005Js-IW for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2016 12:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Dec 2016 17:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25025 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 25025-submit@debbugs.gnu.org id=B25025.148061225420432 (code B ref 25025); Thu, 01 Dec 2016 17:11:02 +0000 Original-Received: (at 25025) by debbugs.gnu.org; 1 Dec 2016 17:10:54 +0000 Original-Received: from localhost ([127.0.0.1]:48942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCUsn-0005JU-Qb for submit@debbugs.gnu.org; Thu, 01 Dec 2016 12:10:54 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46301) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCUsm-0005JI-K0 for 25025@debbugs.gnu.org; Thu, 01 Dec 2016 12:10:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCUse-0008MX-1h for 25025@debbugs.gnu.org; Thu, 01 Dec 2016 12:10:47 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52138) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCUsd-0008MO-Mu; Thu, 01 Dec 2016 12:10:43 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3802 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cCUsc-0001qj-VL; Thu, 01 Dec 2016 12:10:43 -0500 In-reply-to: (message from Noam Postavsky on Wed, 30 Nov 2016 17:10:34 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:126357 Archived-At: > From: Noam Postavsky > Date: Wed, 30 Nov 2016 17:10:34 -0500 > Cc: Clément Pit--Claudel , > 25025@debbugs.gnu.org > > > Confused: how does python-shell-completion-native-disabled-interpreters > > get into this picture? The function which uses it, > > python-shell-completion-native-interpreter-disabled-p, looks at > > python-shell-interpreter, which isn't affected by quoting or by how > > the command is treated. What am I missing? > > This? > > (defun run-python (&optional cmd dedicated show) > ... > (python-shell-make-comint > (or cmd (python-shell-calculate-command)) > ... > > (defun python-shell-make-comint (cmd proc-name &optional show internal) > ... > (let* ((cmdlist (split-string-and-unquote cmd)) > (interpreter (car cmdlist)) > (args (cdr cmdlist)) > (buffer (apply #'make-comint-in-buffer proc-name > proc-buffer-name > interpreter nil args)) > ... > ;; Users can override the interpreter and args > ;; interactively when calling `run-python', let-binding > ;; these allows having the new right values in all > ;; setup code that is done in `inferior-python-mode', > ;; which is important, especially for prompt detection. > (python-shell--interpreter interpreter) > (python-shell--interpreter-args > (mapconcat #'identity args " "))) > (with-current-buffer buffer > (inferior-python-mode)) > ... > > (define-derived-mode inferior-python-mode comint-mode "Inferior Python" > ... > ;; Users can interactively override default values for > ;; `python-shell-interpreter' and `python-shell-interpreter-args' > ;; when calling `run-python'. This ensures values let-bound in > ;; `python-shell-make-comint' are locally set if needed. > (set (make-local-variable 'python-shell-interpreter) > (or python-shell--interpreter python-shell-interpreter)) > (set (make-local-variable 'python-shell-interpreter-args) > (or python-shell--interpreter-args python-shell-interpreter-args)) > ... Thanks. So the problematic scenario is that the user sets python-shell-interpreter to something we already checked, and then manually feeds us with a command that invokes a different Python interpreter, is that it? Is that a frequent use case, which we should care about? Just to produce a warning? Even if we do want to care about, we could try matching the beginning of the command, perhaps after an optional quote character, and if we don't recognize the interpreter, do nothing. Would that be sufficient?