diff options
| author | Fabián Ezequiel Gallina | 2014-07-19 16:19:47 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2014-07-19 16:19:47 -0300 |
| commit | eb8cb39e8930b476e20bb8434e28a350e46ece34 (patch) | |
| tree | 5471a8d50ebfbdc9564b0d5a31850a72b9912343 | |
| parent | d949ade3c101981d015b3d78d061bdff584df13a (diff) | |
| download | emacs-eb8cb39e8930b476e20bb8434e28a350e46ece34.tar.gz emacs-eb8cb39e8930b476e20bb8434e28a350e46ece34.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 37 |
2 files changed, 27 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2a1266a6031..437b2225ce1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-07-19 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 2 | |||
| 3 | Fix Python shell prompts detection for remote hosts. | ||
| 4 | * progmodes/python.el (python-shell-prompt-detect): Replace | ||
| 5 | call-process with process-file and make it more robust. | ||
| 6 | |||
| 1 | 2014-07-17 Fabián Ezequiel Gallina <fgallina@gnu.org> | 7 | 2014-07-17 Fabián Ezequiel Gallina <fgallina@gnu.org> |
| 2 | 8 | ||
| 3 | Autodetect Python shell prompts. (Bug#17370) | 9 | Autodetect Python shell prompts. (Bug#17370) |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e49d5882a61..870640e4c55 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1864,24 +1864,29 @@ detection and just returns nil." | |||
| 1864 | (when python-shell-prompt-detect-enabled | 1864 | (when python-shell-prompt-detect-enabled |
| 1865 | (let* ((process-environment (python-shell-calculate-process-environment)) | 1865 | (let* ((process-environment (python-shell-calculate-process-environment)) |
| 1866 | (exec-path (python-shell-calculate-exec-path)) | 1866 | (exec-path (python-shell-calculate-exec-path)) |
| 1867 | (python-code-file | 1867 | (code (concat |
| 1868 | (python-shell--save-temp-file | 1868 | "import sys\n" |
| 1869 | (concat | 1869 | "ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]\n" |
| 1870 | "import sys\n" | 1870 | ;; JSON is built manually for compatibility |
| 1871 | "ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]\n" | 1871 | "ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps)\n" |
| 1872 | ;; JSON is built manually for compatibility | 1872 | "print (ps_json)\n" |
| 1873 | "ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps)\n" | 1873 | "sys.exit(0)\n")) |
| 1874 | "print (ps_json)\n" | ||
| 1875 | "sys.exit(0)\n"))) | ||
| 1876 | (output | 1874 | (output |
| 1877 | (with-temp-buffer | 1875 | (with-temp-buffer |
| 1878 | (call-process | 1876 | ;; TODO: improve error handling by using |
| 1879 | (executable-find python-shell-interpreter) | 1877 | ;; `condition-case' and displaying the error message to |
| 1880 | python-code-file | 1878 | ;; the user in the no-prompts warning. |
| 1881 | '(t nil) | 1879 | (ignore-errors |
| 1882 | nil | 1880 | (let ((code-file (python-shell--save-temp-file code))) |
| 1883 | python-shell-interpreter-interactive-arg) | 1881 | ;; Use `process-file' as it is remote-host friendly. |
| 1884 | (ignore-errors (delete-file python-code-file)) | 1882 | (process-file |
| 1883 | (executable-find python-shell-interpreter) | ||
| 1884 | code-file | ||
| 1885 | '(t nil) | ||
| 1886 | nil | ||
| 1887 | python-shell-interpreter-interactive-arg) | ||
| 1888 | ;; Try to cleanup | ||
| 1889 | (delete-file code-file))) | ||
| 1885 | (buffer-string))) | 1890 | (buffer-string))) |
| 1886 | (prompts | 1891 | (prompts |
| 1887 | (catch 'prompts | 1892 | (catch 'prompts |