mirror of https://github.com/python/cpython.git
(py-execute-region): Hack around the different behavior and switch
semantics between CPython/JPython when the script source is piped to stdin.
This commit is contained in:
parent
99ff8c4361
commit
34d8317013
|
@ -1215,8 +1215,11 @@ is inserted at the end. See also the command `py-clear-queue'."
|
||||||
(cond
|
(cond
|
||||||
;; always run the code in its own asynchronous subprocess
|
;; always run the code in its own asynchronous subprocess
|
||||||
(async
|
(async
|
||||||
(let* ((buf (generate-new-buffer-name py-output-buffer)))
|
(let* ((buf (generate-new-buffer-name py-output-buffer))
|
||||||
(start-process py-which-bufname buf py-which-shell "-u" file)
|
;; TBD: a horrible hack, but why create new Custom variables?
|
||||||
|
(arg (if (string-equal py-which-bufname "Python")
|
||||||
|
"-u" "")))
|
||||||
|
(start-process py-which-bufname buf py-which-shell arg file)
|
||||||
(pop-to-buffer buf)
|
(pop-to-buffer buf)
|
||||||
(py-postprocess-output-buffer buf)
|
(py-postprocess-output-buffer buf)
|
||||||
))
|
))
|
||||||
|
@ -1230,18 +1233,22 @@ is inserted at the end. See also the command `py-clear-queue'."
|
||||||
(setq py-file-queue (append py-file-queue (list file)))
|
(setq py-file-queue (append py-file-queue (list file)))
|
||||||
(setq py-exception-buffer (cons file (current-buffer))))
|
(setq py-exception-buffer (cons file (current-buffer))))
|
||||||
(t
|
(t
|
||||||
;; otherwise either run it synchronously in a subprocess
|
;; TBD: a horrible hack, buy why create new Custom variables?
|
||||||
(shell-command-on-region start end py-which-shell py-output-buffer)
|
(let ((cmd (concat py-which-shell
|
||||||
;; shell-command-on-region kills the output buffer if it never
|
(if (string-equal py-which-bufname "JPython")
|
||||||
;; existed and there's no output from the command
|
" -" ""))))
|
||||||
(if (not (get-buffer py-output-buffer))
|
;; otherwise either run it synchronously in a subprocess
|
||||||
(message "No output.")
|
(shell-command-on-region start end cmd py-output-buffer)
|
||||||
(setq py-exception-buffer (current-buffer))
|
;; shell-command-on-region kills the output buffer if it never
|
||||||
(let ((err-p (py-postprocess-output-buffer py-output-buffer)))
|
;; existed and there's no output from the command
|
||||||
(pop-to-buffer py-output-buffer)
|
(if (not (get-buffer py-output-buffer))
|
||||||
(if err-p
|
(message "No output.")
|
||||||
(pop-to-buffer py-exception-buffer)))
|
(setq py-exception-buffer (current-buffer))
|
||||||
))
|
(let ((err-p (py-postprocess-output-buffer py-output-buffer)))
|
||||||
|
(pop-to-buffer py-output-buffer)
|
||||||
|
(if err-p
|
||||||
|
(pop-to-buffer py-exception-buffer)))
|
||||||
|
)))
|
||||||
)))
|
)))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue