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).
This commit is contained in:
Jack Kamm 2020-05-28 07:29:31 -07:00
parent 516c038e5f
commit d73fd145c0
2 changed files with 3 additions and 7 deletions

View File

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

View File

@ -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\"