emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 r117388: Fix Python shell prompts detection for r


From: Fabián Ezequiel Gallina
Subject: [Emacs-diffs] emacs-24 r117388: Fix Python shell prompts detection for remote hosts.
Date: Sat, 19 Jul 2014 19:20:03 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117388
revision-id: address@hidden
parent: address@hidden
committer: Fabián Ezequiel Gallina <address@hidden>
branch nick: emacs-24
timestamp: Sat 2014-07-19 16:19:47 -0300
message:
  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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/python.el       python.el-20091113204419-o5vbwnq5f7feedwu-3008
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-07-19 13:13:07 +0000
+++ b/lisp/ChangeLog    2014-07-19 19:19:47 +0000
@@ -1,3 +1,9 @@
+2014-07-19  Fabián Ezequiel Gallina  <address@hidden>
+
+       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  <address@hidden>
 
        Autodetect Python shell prompts.  (Bug#17370)

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2014-07-19 13:13:07 +0000
+++ b/lisp/progmodes/python.el  2014-07-19 19:19:47 +0000
@@ -1864,24 +1864,29 @@
   (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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]