In Emacs 28, `python-shell-send-string' prints an additional newline
between the prompt and output (among other things, so you can tell
whether or not the inferior process is busy at any given time).

However, this interferes with ob-python, see e.g.
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50514

The attached patch indicates how to solve the problem.  As a permanent
solution, I would suggest to replace org-babel-chomp and actually strip
whitespace from both ends of the string outputted from the Python
interpreter.  (IPython even has a configuration option to add extra
whitespace before or after the output.)

diff --git a/lisp/org/ob-python.el b/lisp/org/ob-python.el
index 7911205d08..e3714964b7 100644
--- a/lisp/org/ob-python.el
+++ b/lisp/org/ob-python.el
@@ -352,7 +352,7 @@ org-babel-python--send-string
 		   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))))))
+      (org-babel-chomp (substring string-buffer 1 (match-beginning 0))))))
 
 (defun org-babel-python-evaluate-session
     (session body &optional result-type result-params)

Reply via email to