ob-python: Fix discrepancy of single/multi-line code blocks

* lisp/ob-python.el (org-babel-python-evaluate-session): Fix
discrepancy between how single-line and multiline code blocks return
output.

For example, before this commit, the 2 blocks behaved differently:

+begin_src python :session :results output
  pass
  "foo"
+end_src

+RESULTS:

+begin_src python :session :results output
  "foo"
+end_src

+RESULTS:
: 'foo'

But now, they both behave as the former.
This commit is contained in:
Jack Kamm 2020-08-24 15:24:47 -07:00
parent 66537267eb
commit 30a50d1c0f
1 changed files with 6 additions and 8 deletions

View File

@ -330,14 +330,12 @@ last statement in BODY, as elisp."
(results
(pcase result-type
(`output
(let ((body (if (string-match-p ".\n+." body) ; Multiline
(let ((tmp-src-file (org-babel-temp-file
"python-")))
(with-temp-file tmp-src-file (insert body))
(format org-babel-python--exec-tmpfile
(org-babel-process-file-name
tmp-src-file 'noquote)))
body)))
(let ((body (let ((tmp-src-file (org-babel-temp-file
"python-")))
(with-temp-file tmp-src-file (insert body))
(format org-babel-python--exec-tmpfile
(org-babel-process-file-name
tmp-src-file 'noquote)))))
(mapconcat
#'org-trim
(butlast