]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/python.el: Be more careful about temp file removal
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 14 Apr 2019 22:45:35 +0000 (18:45 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 14 Apr 2019 22:45:35 +0000 (18:45 -0400)
(python-shell-prompt-detect): Use unwind-protect to try and not leave
file behind in case of error.

lisp/progmodes/python.el

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