branch: externals/org
commit 1eb598758980d5fa4d7bb21c98dfc56f42cae59a
Author: Jack Kamm <jackk...@gmail.com>
Commit: Jack Kamm <jackk...@gmail.com>

    ob-python: Check for end of output in org-babel-python-send-string
    
    This is an attempt to mitigate occasional leaky prompts in CI. My
    current hypothesis is that this could happen if the comint-output ends
    between `org-babel-python-eoe-indicator' and the new prompt. Then the
    new prompt could be injected into the output of the next unit test. To
    avoid this, check we are at an ending prompt before exiting
    `org-babel-python-send-string'.
    
    https://list.orgmode.org/873506j7ky.fsf@localhost/
    
    * lisp/ob-python.el (org-babel-python-send-string): Add check for
    `python-shell-comint-end-of-output-p' to stop while loop accepting
    process output.
---
 lisp/ob-python.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 9d655494de..e7cc4d5a84 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -399,9 +399,10 @@ finally:
             (org-babel-python-without-earmuffs session)))
        (python-shell-send-string body))
       ;; same as `python-shell-comint-end-of-output-p' in emacs-25.1+
-      (while (not (string-match
-                  org-babel-python-eoe-indicator
-                  string-buffer))
+      (while (not (and (python-shell-comint-end-of-output-p string-buffer)
+                       (string-match
+                       org-babel-python-eoe-indicator
+                       string-buffer)))
        (accept-process-output (get-buffer-process (current-buffer))))
       (org-babel-chomp (substring string-buffer 0 (match-beginning 0))))))
 

Reply via email to