emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: ob-python issue in Emacs 28 [9.4.4]
@ 2021-09-12  6:41 Augusto Stoffel
  2021-09-14  5:56 ` Jack Kamm
  0 siblings, 1 reply; 3+ messages in thread
From: Augusto Stoffel @ 2021-09-12  6:41 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug: ob-python issue in Emacs 28 [9.4.4]
  2021-09-12  6:41 Bug: ob-python issue in Emacs 28 [9.4.4] Augusto Stoffel
@ 2021-09-14  5:56 ` Jack Kamm
  2021-09-14 19:40   ` Augusto Stoffel
  0 siblings, 1 reply; 3+ messages in thread
From: Jack Kamm @ 2021-09-14  5:56 UTC (permalink / raw)
  To: Augusto Stoffel, emacs-orgmode

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug: ob-python issue in Emacs 28 [9.4.4]
  2021-09-14  5:56 ` Jack Kamm
@ 2021-09-14 19:40   ` Augusto Stoffel
  0 siblings, 0 replies; 3+ messages in thread
From: Augusto Stoffel @ 2021-09-14 19:40 UTC (permalink / raw)
  To: Jack Kamm; +Cc: emacs-orgmode

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-14 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-12  6:41 Bug: ob-python issue in Emacs 28 [9.4.4] Augusto Stoffel
2021-09-14  5:56 ` Jack Kamm
2021-09-14 19:40   ` Augusto Stoffel

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).