diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 37 |
1 files changed, 21 insertions, 16 deletions
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 |