From: ian martins <ianxm@jhu.edu>
To: Philip Blagoveschensky <philip@crabman.me>
Cc: emacs-orgmode@gnu.org
Subject: Re: Bug: org-babel python with :results value sends function definition with a statement after a for loop to the shell incorrectly [9.3.6 (9.3.6-elpa @ /home/username/.emacs.d/elpa/org-9.3.6/)]
Date: Tue, 7 Jul 2020 07:31:45 -0400 [thread overview]
Message-ID: <CAC=rjb60fKJzXYy=_bSAgGog=aDGNt19YipeJYyFds+=4L2dzA@mail.gmail.com> (raw)
In-Reply-To: <5c1caa08-6c08-ebb9-ee81-76143c3a60b2@crabman.me>
[-- Attachment #1: Type: text/plain, Size: 3356 bytes --]
I was able to reproduce the error. I started emacs without my init file
(emacs -q) and then
,----
| (add-to-list 'load-path "~/code/elisp/org-mode/lisp")
| (require 'ob-python)
| (org-babel-do-load-languages 'org-babel-load-languages `((python . t)))
`----
in scratch, and then ran your test. I got the same errors you described. I
redid the test but loaded the lastest org-mode and there was no error. This
means you probably don't need to debug this. It has been fixed in the
latest version, but the fix hasn't been updated in the elpa package yet.
you can either wait for the next release or pull the latest code from the
repo.
On Mon, Jul 6, 2020 at 3:18 PM Philip Blagoveschensky <philip@crabman.me>
wrote:
> Hi Ian,
>
> >Do you have the same issue if you aren't using a session?
>
> If I run the following code block (this time I am using python 3, so
> there are parens in the print line)
>
> #+begin_src python
> def foobar():
> for i in range(5):
> pass
> print("hello world")
> return 3
>
> return foobar()
> #+end_src
>
> I get
>
> #+RESULTS:
> : 3
>
> so I know it worked fine.
>
> But if I add session like this:
>
> #+begin_src python :session bug_report
> def foobar():
> for i in range(5):
> pass
> print("hello world")
> return 3
>
> return foobar()
> #+end_src
>
> then in *bug_report* I get
>
> >>> def foobar():
> ... for i in range(5):
> ... pass
> ...
> >>> print("hello world")
> File "<stdin>", line 1
> print("hello world")
> ^
> IndentationError: unexpected indent
> return 3
> >>>
> File "<stdin>", line 1
> return 3
> ^
> IndentationError: unexpected indent
> >>> return foobar()
> >>>
> File "<stdin>", line 1
> SyntaxError: 'return' outside function
> >>> open('/tmp/babel-D0mRnD/python-CJ6UtT', 'w').write(str(_))
> >>>
> 20
> >>>
> >>> 'org_babel_python_eoe'
> >>> 'org_babel_python_eoe'
> >>>
>
> >Are you using tabs or spaces?
>
> I used spaces. 4 spaces per indentation level, to be exact.
>
> Also, FYI, as it might be relevant information, the shell buffer
> contents I posted above happen if the session has been created
> previously. If, instead, this is the first time I run some code in this
> session, then I also get another error - NameError (see below). Below
> you can see the contents of *bug_report* buffer if I run this code cell
> in a not-yet-existing session.
>
> def foobar():
> Python 3.8.2 | packaged by conda-forge | (default, Mar 5 2020, 17:11:00)
> [GCC 7.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> ... for i in range(5):
> ... pass
> ...
> >>> print("hello world")
> File "<stdin>", line 1
> print("hello world")
> ^
> IndentationError: unexpected indent return 3
>
> >>>
> File "<stdin>", line 1
> return 3
> ^
> IndentationError: unexpected indent
> >>> return foobar()
> >>>
> File "<stdin>", line 1
> SyntaxError: 'return' outside function
> >>> open('/tmp/babel-D0mRnD/python-MsDjEk', 'w').write(str(_))
> >>>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name '_' is not defined
> >>>
> >>> 'org_babel_python_eoe'
> >>> 'org_babel_python_eoe'
> >>>
>
> If you have a suggestion on how to debug this, feel free to tell.
>
[-- Attachment #2: Type: text/html, Size: 4724 bytes --]
next prev parent reply other threads:[~2020-07-07 11:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-30 11:09 Bug: org-babel python with :results value sends function definition with a statement after a for loop to the shell incorrectly [9.3.6 (9.3.6-elpa @ /home/username/.emacs.d/elpa/org-9.3.6/)] Philip Blagoveschensky
2020-07-06 12:57 ` ian martins
2020-07-06 19:18 ` Philip Blagoveschensky
2020-07-07 11:31 ` ian martins [this message]
2020-07-19 15:33 ` Jack Kamm
2020-10-10 23:57 ` Jack Kamm
-- strict thread matches above, loose matches on Subject: below --
2020-07-01 16:55 Philip Blagoveschensky
2020-07-01 18:48 ` Andreas Röhler
2020-07-01 19:05 ` ian martins
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAC=rjb60fKJzXYy=_bSAgGog=aDGNt19YipeJYyFds+=4L2dzA@mail.gmail.com' \
--to=ianxm@jhu.edu \
--cc=emacs-orgmode@gnu.org \
--cc=philip@crabman.me \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).