From 30a50d1c0fe6b459f9d0759d8cd4a6bfa7b82c7d Mon Sep 17 00:00:00 2001 From: Jack Kamm Date: Mon, 24 Aug 2020 15:24:47 -0700 Subject: [PATCH] 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. --- lisp/ob-python.el | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lisp/ob-python.el b/lisp/ob-python.el index 0e3c79522..bf3b4c7ef 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -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