* lisp/progmodes/python.el: Be more careful about temp file removal

(python-shell-prompt-detect): Use unwind-protect to try and not leave
file behind in case of error.
This commit is contained in:
Stefan Monnier 2019-04-14 18:45:35 -04:00
parent b3cab4199a
commit 7a608fc6f3

View file

@ -2266,6 +2266,7 @@ detection and just returns nil."
;; carriage returns in unbuffered mode. ;; carriage returns in unbuffered mode.
(let ((inhibit-eol-conversion (getenv "PYTHONUNBUFFERED"))) (let ((inhibit-eol-conversion (getenv "PYTHONUNBUFFERED")))
(python-shell--save-temp-file code)))) (python-shell--save-temp-file code))))
(unwind-protect
;; Use `process-file' as it is remote-host friendly. ;; Use `process-file' as it is remote-host friendly.
(process-file (process-file
interpreter interpreter
@ -2274,7 +2275,7 @@ detection and just returns nil."
nil nil
interpreter-arg) interpreter-arg)
;; Try to cleanup ;; Try to cleanup
(delete-file code-file))) (delete-file code-file))))
(buffer-string))) (buffer-string)))
(prompts (prompts
(catch 'prompts (catch 'prompts