[-- Attachment #1: Type: text/plain, Size: 622 bytes --] 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.) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: ob-python.diff --] [-- Type: text/x-patch, Size: 577 bytes --] 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)
Hi Augusto, > 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 Thanks for reporting this, and also for your recent improvements to python.el. Would you be willing to update your patch to use (if (version< emacs-version "28") 0 1) And add a commit message and changelog, so we can push it to master? > 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.) I think this would be problematic, because then it would be impossible to print output with leading or trailing whitespace, which it should be possible to do. Best, Jack
Hi Jack, on a closer consideration, it's better to change python.el in such a way that this problem vanishes. I've submitted the patch to Emacs, so I guess this issue can be considered closed. Best, Augusto