From: Matthew Lundin <mdl@imapmail.org>
To: "Jack Kamm" <jackkamm@gmail.com>,
"Štěpán Němec" <stepnem@gmail.com>,
emacs-orgmode@gnu.org
Subject: Re: Bug: ob-python mangles multiline :var values [9.3.6 (release_9.3.6-397-ga089600)]
Date: Wed, 27 May 2020 13:26:58 -0500 [thread overview]
Message-ID: <87h7w18ca1.fsf@fastmail.fm> (raw)
In-Reply-To: <87a71xtmh0.fsf@gmail.com>
Jack Kamm <jackkamm@gmail.com> writes:
> Hello,
>
> Thanks for reporting. I've just fixed this issue in master (commit
> 6149b6cb6).
>
> The problem was that ob-python adds tab indentation to the code body
> before putting it inside a main() function, which adds spurious
> indentation to multiline strings passed through :var.
>
> I fixed the issue by moving variable assignment from the code body to
> the code preamble, which is executed outside the main() function.
A heads up... I believe this changes the scope of the :var variables,
since they previously were local to the main() function and now they are
declared globally. After this change, some of my existing python source
blocks (i.e., ones in which I attempt to assign a new value to a
variable defined by :var) now generate the following error:
Traceback (most recent call last):
File "<stdin>", line 223, in <module>
File "<stdin>", line 214, in main
UnboundLocalError: local variable 'members' referenced before assignment
I hesitate to call this a bug, since it would be fine to think of
everything within the source block as local and the header :var
declarations as global. But if this is the case, then I think it should
be documented somewhere, especially since this change may break people's
existing source blocks. And I suppose it would be worthwhile to ask: Is
this change consistent with other org-babel modules? Is there a
canonical way that org-babel handles scope?
Best,
Matt
next prev parent reply other threads:[~2020-05-27 18:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 13:16 Bug: ob-python mangles multiline :var values [9.3.6 (release_9.3.6-397-ga089600)] Štěpán Němec
2020-05-24 14:51 ` Jack Kamm
2020-05-27 18:26 ` Matthew Lundin [this message]
2020-05-27 21:46 ` Jack Kamm
2020-05-28 14:39 ` Jack Kamm
2020-06-06 18:24 ` Jack Kamm
2020-06-08 4:29 ` Kyle Meyer
2020-06-10 4:05 ` Jack Kamm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h7w18ca1.fsf@fastmail.fm \
--to=mdl@imapmail.org \
--cc=emacs-orgmode@gnu.org \
--cc=jackkamm@gmail.com \
--cc=stepnem@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.