From d73fd145c00e8c65da54a9b59224fbf22f9c6822 Mon Sep 17 00:00:00 2001 From: Jack Kamm Date: Thu, 28 May 2020 07:29:31 -0700 Subject: [PATCH] ob-python.el: Revert fix for multiline var * lisp/ob-python.el (org-babel-execute:python, org-babel-python-evaluate): Move variable assignment back to body from preamble. * testing/lisp/test-ob-python.el (test-ob-python/multiline-var): Mark unit test for multiline-variable as expected to fail. Reverts 6149b6cb6 which fixed multiline vars in ob-python, but caused a new bug (https://lists.gnu.org/archive/html/emacs-orgmode/2020-05/msg00719.html). --- lisp/ob-python.el | 9 ++------- testing/lisp/test-ob-python.el | 1 + 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lisp/ob-python.el b/lisp/ob-python.el index fbc4e969f..dbcfac08d 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -82,14 +82,10 @@ This function is called by `org-babel-execute-src-block'." (return-val (when (and (eq result-type 'value) (not session)) (cdr (assq :return params)))) (preamble (cdr (assq :preamble params))) - (preamble (concat preamble (and preamble "\n") - (mapconcat #'identity - (org-babel-variable-assignments:python params) - "\n"))) (full-body (org-babel-expand-body:generic (concat body (if return-val (format "\nreturn %s" return-val) "")) - params)) + params (org-babel-variable-assignments:python params))) (result (org-babel-python-evaluate session full-body result-type result-params preamble))) (org-babel-reassemble-table @@ -276,8 +272,7 @@ except Exception: "Evaluate BODY as Python code." (if session (org-babel-python-evaluate-session - session (concat preamble (and preamble "\n") body) - result-type result-params) + session body result-type result-params) (org-babel-python-evaluate-external-process body result-type result-params preamble))) diff --git a/testing/lisp/test-ob-python.el b/testing/lisp/test-ob-python.el index 0721be9f1..763942b16 100644 --- a/testing/lisp/test-ob-python.el +++ b/testing/lisp/test-ob-python.el @@ -174,6 +174,7 @@ _ = 'failure' (org-babel-execute-src-block))))) (ert-deftest test-ob-python/multiline-var () + :expected-result :failed (should (equal "a\nb\nc" (org-test-with-temp-text "#+begin_src python :var text=\"a\\nb\\nc\"