mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-16 19:00:55 -08:00
Fix Python shell prompts detection for remote hosts.
* lisp/progmodes/python.el (python-shell-prompt-detect): Replace call-process with process-file and make it more robust.
This commit is contained in:
parent
d949ade3c1
commit
eb8cb39e89
2 changed files with 27 additions and 16 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
2014-07-19 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
||||||
|
|
||||||
|
Fix Python shell prompts detection for remote hosts.
|
||||||
|
* progmodes/python.el (python-shell-prompt-detect): Replace
|
||||||
|
call-process with process-file and make it more robust.
|
||||||
|
|
||||||
2014-07-17 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
2014-07-17 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
||||||
|
|
||||||
Autodetect Python shell prompts. (Bug#17370)
|
Autodetect Python shell prompts. (Bug#17370)
|
||||||
|
|
|
||||||
|
|
@ -1864,24 +1864,29 @@ detection and just returns nil."
|
||||||
(when python-shell-prompt-detect-enabled
|
(when python-shell-prompt-detect-enabled
|
||||||
(let* ((process-environment (python-shell-calculate-process-environment))
|
(let* ((process-environment (python-shell-calculate-process-environment))
|
||||||
(exec-path (python-shell-calculate-exec-path))
|
(exec-path (python-shell-calculate-exec-path))
|
||||||
(python-code-file
|
(code (concat
|
||||||
(python-shell--save-temp-file
|
"import sys\n"
|
||||||
(concat
|
"ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]\n"
|
||||||
"import sys\n"
|
;; JSON is built manually for compatibility
|
||||||
"ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]\n"
|
"ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps)\n"
|
||||||
;; JSON is built manually for compatibility
|
"print (ps_json)\n"
|
||||||
"ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps)\n"
|
"sys.exit(0)\n"))
|
||||||
"print (ps_json)\n"
|
|
||||||
"sys.exit(0)\n")))
|
|
||||||
(output
|
(output
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(call-process
|
;; TODO: improve error handling by using
|
||||||
(executable-find python-shell-interpreter)
|
;; `condition-case' and displaying the error message to
|
||||||
python-code-file
|
;; the user in the no-prompts warning.
|
||||||
'(t nil)
|
(ignore-errors
|
||||||
nil
|
(let ((code-file (python-shell--save-temp-file code)))
|
||||||
python-shell-interpreter-interactive-arg)
|
;; Use `process-file' as it is remote-host friendly.
|
||||||
(ignore-errors (delete-file python-code-file))
|
(process-file
|
||||||
|
(executable-find python-shell-interpreter)
|
||||||
|
code-file
|
||||||
|
'(t nil)
|
||||||
|
nil
|
||||||
|
python-shell-interpreter-interactive-arg)
|
||||||
|
;; Try to cleanup
|
||||||
|
(delete-file code-file)))
|
||||||
(buffer-string)))
|
(buffer-string)))
|
||||||
(prompts
|
(prompts
|
||||||
(catch 'prompts
|
(catch 'prompts
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue