GNU bug report logs - #20744
python.el tries to undo shell quoting with split-string-and-unquote

Previous Next

Package: emacs;

Reported by: Da Zhang <zhangda82 <at> gmail.com>

Date: Fri, 5 Jun 2015 16:35:02 UTC

Severity: normal

Tags: confirmed, fixed

Merged with 25025

Found in version 25.1

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


Message #53 received at 20744 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Da Zhang <zhangda82 <at> gmail.com>
Cc: 20744 <at> debbugs.gnu.org, eliz <at> gnu.org
Subject: Re: bug#20744: shell-quote-argument in Emacs 24.5 and Emacs 25 on
 Windows cannot figure out path correctly
Date: Tue, 09 Aug 2016 20:51:24 -0400
retitle 20744 python.el tries to undo shell quoting with split-string-and-unquote
tags 20744 confirmed
found 20744 25.1
quit

Da Zhang <zhangda82 <at> gmail.com> writes:

> From: Da Zhang <zhangda82 <at> gmail.com>
> To: bug-gnu-emacs <at> gnu.org
> Subject: 24.5; shell-quote-argument in Emacs 24.5 and Emacs 25 on Windows cannot figure out path correctly
> --text follows this line--
>
> Dear Emacs developers/maintainers,
>
> I am writing this email to report an issue that has been bothering me
> for a while.
>
> I use python mode (python.el) for some python programming. When I invoke
> the command python-shell-send-buffer, my Emacs always reports "Searching
> for program: no such file or directory,
> c\:/Anaconda3/Scripts/ipython.exe".
>
[...]
>
> The function call 
> (shell-quote-argument (executable-find python-shell-interpreter))
> changed the path of my python interpreter from
> "c:/Anaconda3/Scripts/ipython.exe"
> to
> "c\\:/Anaconda3/Scripts/ipython.exe".
>
> I worked around this problem by replacing the function call
> (shell-quote-argument (executable-find python-shell-interpreter))
> with
> (executable-find python-shell-interpreter) ;; edited by DZ on
> 2015/06/05: (shell-quote-argument) caused the problem of
> "c\\:/Anaconda3/Scripts/ipython.exe"
>
> To further analyze the problem, I found the function
> shell-quote-argument defined in subr.el does not deal with the case when
> bash from cygwin is used.
>
[...]

Actually, bash, regardless of being on cygwin or not, should have no
problem with an escaped ":".  The actual problem here is that python.el
is using shell-quote-argument but then not using a shell.  The result of
python-shell-calculate-command (formerly known as
python-shell-parse-command) gets passed to python-shell-make-comint as
the CMD argument:

(defun python-shell-make-comint (cmd proc-name &optional show internal)
  [...]
          (let* ((cmdlist (split-string-and-unquote cmd))
                 (buffer (apply #'make-comint-in-buffer proc-name proc-buffer-name
                                interpreter nil args))

make-comint-in-buffer uses start-file-process, i.e., no shell is called.
So python.el is trying to undo shell-quote-argument with
split-string-and-unquote, this is the bug.

To see this on any system, compare

    C-u M-x run-python RET 'python' -i

this fails, while

    C-u M-x run-python RET "python" -i

this succeeds (assuming you have python in exec-path).





This bug report was last modified 7 years and 277 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.