]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Python shell prompts detection for remote hosts.
authorFabián Ezequiel Gallina <fgallina@gnu.org>
Sat, 19 Jul 2014 19:19:47 +0000 (16:19 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Sat, 19 Jul 2014 19:19:47 +0000 (16:19 -0300)
* lisp/progmodes/python.el (python-shell-prompt-detect): Replace
call-process with process-file and make it more robust.

lisp/ChangeLog
lisp/progmodes/python.el

index 2a1266a6031e33bf02f817b3a1953c74820d34f3..437b2225ce1042b65802b3c28d4abe749b474fa8 100644 (file)
@@ -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>
 
        Autodetect Python shell prompts.  (Bug#17370)
index e49d5882a616a571c2044783a56a34af1020c448..870640e4c5573fbb96bd3d0c7dc76fdc95696ca1 100644 (file)
@@ -1864,24 +1864,29 @@ detection and just returns nil."
   (when python-shell-prompt-detect-enabled
     (let* ((process-environment (python-shell-calculate-process-environment))
            (exec-path (python-shell-calculate-exec-path))
-           (python-code-file
-            (python-shell--save-temp-file
-             (concat
-              "import sys\n"
-              "ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]\n"
-              ;; JSON is built manually for compatibility
-              "ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps)\n"
-              "print (ps_json)\n"
-              "sys.exit(0)\n")))
+           (code (concat
+                  "import sys\n"
+                  "ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]\n"
+                  ;; JSON is built manually for compatibility
+                  "ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps)\n"
+                  "print (ps_json)\n"
+                  "sys.exit(0)\n"))
            (output
             (with-temp-buffer
-              (call-process
-               (executable-find python-shell-interpreter)
-               python-code-file
-               '(t nil)
-               nil
-               python-shell-interpreter-interactive-arg)
-              (ignore-errors (delete-file python-code-file))
+              ;; TODO: improve error handling by using
+              ;; `condition-case' and displaying the error message to
+              ;; the user in the no-prompts warning.
+              (ignore-errors
+                (let ((code-file (python-shell--save-temp-file code)))
+                  ;; Use `process-file' as it is remote-host friendly.
+                  (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)))
            (prompts
             (catch 'prompts