From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Beckman Subject: Re: Bug? Improper interaction with python variable _ ? Date: Sun, 4 Oct 2015 22:22:25 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e013cbd32dbab34052154b20f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiyEF-0005Qm-Mx for emacs-orgmode@gnu.org; Mon, 05 Oct 2015 01:22:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZiyEE-0007np-3q for emacs-orgmode@gnu.org; Mon, 05 Oct 2015 01:22:27 -0400 Received: from mail-ig0-x22b.google.com ([2607:f8b0:4001:c05::22b]:37648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiyED-0007nl-Sd for emacs-orgmode@gnu.org; Mon, 05 Oct 2015 01:22:26 -0400 Received: by igbni9 with SMTP id ni9so50133958igb.0 for ; Sun, 04 Oct 2015 22:22:25 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --089e013cbd32dbab34052154b20f Content-Type: text/plain; charset=UTF-8 Correction: The first elisp-block should contain another command Here is the corrected org-mode file, top-to-bottom #+TITLE: Org-Babel Bug? #+AUTHOR: Brian Beckman #+EMAIL: bc.beckman@gmail.com #+BEGIN_SRC emacs-lisp :exports results :results none (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) (setq org-confirm-babel-evaluate nil) (org-babel-map-src-blocks nil (org-babel-remove-result)) #+end_src * Mystery Number 1 The first line of the first block must be blank, or we must =C-c C-c= the block two times. But we want to eval the entire file /via/ =C-c C-v C-b=, and we found that the first line must be empty. If you =C-c C-v C-b= this entire file, the python session buffer, named =*bug-org-babel*=, contains an error message that suggests the variable =_= is implicated in an error. We expect the value of this first block to be 999. Make sure that the python session is clear by typing =quit()=, then evaluate this entire file by =C-c C-v C-b=. #+NAME: probe #+BEGIN_SRC python :session bug-org-babel :exports both :results value 999 #+END_SRC #+RESULTS: probe : 999 * Mystery Number 2 Now, we set the value of the variable =_= to something arbitray. In a real scenario, this variable may be set casually in a loop or some other context. The variable =_= is often recommended for /ad-hoc/ use, as in "don't care." #+NAME: second-probe #+BEGIN_SRC python :session bug-org-babel :exports both :results value _ = 42 _ #+END_SRC #+RESULTS: second-probe : 42 But now, all blocks with =:results value= return the value of =_=. We broke org-babel! #+NAME: third-probe #+BEGIN_SRC python :session bug-org-babel :exports both :results value 999 #+END_SRC #+RESULTS: third-probe : 42 On Sun, Oct 4, 2015 at 10:12 PM, Brian Beckman wrote: > Please see the gist below for a self-explaining example > copied here for convenience. Emacs 24.5.1 with org-mode > 8 something (not sure how to get it to report its exact > version)... a very late version, I am sure. Verified with > no init.el, that is, with emacs -Q > > https://gist.github.com/rebcabin/37f800da658f4b23ceaa > > #+TITLE: Org-Babel Bug? > #+AUTHOR: Brian Beckman > #+EMAIL: bc.beckman@gmail.com > > #+BEGIN_SRC emacs-lisp :exports results :results none > (setq org-confirm-babel-evaluate nil) > (org-babel-map-src-blocks nil (org-babel-remove-result)) > #+end_src > > * Mystery Number 1 > > The first line of the first block must be blank, or we must =C-c C-c= the block > two times. But we want to eval the entire file /via/ =C-c C-v C-b=, and we found > that the first line must be empty. > > If you =C-c C-v C-b= this entire file, the python session buffer, named > =*bug-org-babel*=, contains an error message that suggests the variable =_= is > implicated in an error. > > We expect the value of this first block to be 999. Make sure that the python > session is clear by typing =quit()=, then evaluate this entire file by > =C-c C-v C-b=. > > #+NAME: probe > #+BEGIN_SRC python :session bug-org-babel :exports both :results value > > 999 > #+END_SRC > > #+RESULTS: probe > : 999 > > * Mystery Number 2 > > Now, we set the value of the variable =_= to something arbitray. In a real > scenario, this variable may be set casually in a loop or some other context. The > variable =_= is often recommended for /ad-hoc/ use, as in "don't care." > > #+NAME: second-probe > #+BEGIN_SRC python :session bug-org-babel :exports both :results value > _ = 42 > _ > #+END_SRC > > #+RESULTS: second-probe > : 42 > > But now, all blocks with =:results value= return the value of =_=. We broke > org-babel! > > #+NAME: third-probe > #+BEGIN_SRC python :session bug-org-babel :exports both :results value > 999 > #+END_SRC > > #+RESULTS: third-probe > : 42 > > > --089e013cbd32dbab34052154b20f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Correction: The first elisp-block should contain another comma= nd

Here is the corrected org-mode file, top-to-bottom

#+TIT= LE: Org-Babel Bug?
#+AUTHOR: Brian Beckman
#+EMAIL: bc.beckman@gmail.com

#+BEGIN_SRC emacs-li= sp :exports results :results none
=C2=A0 (org-babel-do-load-languages=C2=A0=C2=A0=C2=A0 'org-babel-load-languages '((python . t)))
= =C2=A0 (setq org-confirm-babel-evaluate nil)
=C2=A0 (org-babel-map-src-b= locks nil (org-babel-remove-result))
#+end_src

* Mystery Number 1=

The first line of the first block must be blank, or we must =3DC-c = C-c=3D the block
two times. But we want to eval the entire file /via/ = =3DC-c C-v C-b=3D, and we found
that the first line must be empty.
If you =3DC-c C-v C-b=3D this entire file, the python session buffer, nam= ed
=3D*bug-org-babel*=3D, contains an error message that suggests the va= riable =3D_=3D is
implicated in an error.

We expect the value of = this first block to be 999.=C2=A0 Make sure that the python
session is c= lear by typing =3Dquit()=3D, then evaluate this entire file by
=3DC-c C-= v C-b=3D.

#+NAME: probe
#+BEGIN_SRC python :session bug-org-babel= :exports both :results value

=C2=A0 999
#+END_SRC

#+RESUL= TS: probe
: 999

* Mystery Number 2

Now, we set the value o= f the variable =3D_=3D to something arbitray. In a real
scenario, this v= ariable may be set casually in a loop or some other context. The
variabl= e =3D_=3D is often recommended for /ad-hoc/ use, as in "don't care= ."

#+NAME: second-probe
#+BEGIN_SRC python :session bug-org-= babel :exports both :results value
=C2=A0 _ =3D 42
=C2=A0 _
#+END_= SRC

#+RESULTS: second-probe
: 42

But now, all blocks with = =3D:results value=3D return the value of =3D_=3D. We broke
org-babel!=C2= =A0

#+NAME: third-probe
#+BEGIN_SRC python :session bug-org-babe= l :exports both :results value
=C2=A0 999
#+END_SRC

#+RESULTS:= third-probe
: 42



=
On Sun, Oct 4, 2015 at 10:12 PM, Brian Beckm= an <bc.beckman@gmail.com> wrote:
Please see the gist below for a self-explaining exam= ple
copied here for convenience.=C2=A0 Emacs 24.5.1 with org-mode
<= /div>
8 something (not sure how to get it to report its exact
version)... a= very late version, I am sure.=C2=A0 Verified with
no init.el, that is= , with emacs -Q

https://gist.github.com/rebcabin/37f800da= 658f4b23ceaa

#+TITLE: Org-Babel Bug?
#+AUTHOR: Brian Beckman
#+EMAIL: bc.beckm=
an@gmail.com

#+BEGIN_SRC emacs-lisp :exports results :results none
  (setq org-confirm-babel-evaluate nil)
  (org-babel-map-src-blocks nil (org-babel-remove-result))
#+end_src

* Mystery Number 1

The first line of the first block must be blank, or we must =3DC-c C-c=3D t=
he block
two times. But we want to eval the entire file /via/ =3DC-c C-v C-b=3D, and=
 we found
that the first line must be empty.

If you =3DC-c C-v C-b=3D this entire file, the python session buffer, named
=3D*bug-org-babel*=3D, contains an error message that suggests the variable=
 =3D_=3D is
implicated in an error.

We expect the value of this first block to be 999.  Make sure that the pyth=
on
session is clear by typing =3Dquit()=3D, then evaluate this entire file by
=3DC-c C-v C-b=3D.

#+NAME: probe
#+BEGIN_SRC python :session bug-org-babel :exports both :results value

  999
#+END_SRC

#+RESULTS: probe
: 999

* Mystery Number 2

Now, we set the value of the variable =3D_=3D to something arbitray. In a r=
eal
scenario, this variable may be set casually in a loop or some other context=
. The
variable =3D_=3D is often recommended for /ad-hoc/ use, as in "don'=
;t care."

#+NAME: second-probe
#+BEGIN_SRC python :session bug-org-babel :exports both :results value
  _ =3D 42
  _
#+END_SRC

#+RESULTS: second-probe
: 42

But now, all blocks with =3D:results value=3D return the value of =3D_=3D. =
We broke
org-babel! =20

#+NAME: third-probe
#+BEGIN_SRC python :session bug-org-babel :exports both :results value
  999
#+END_SRC

#+RESULTS: third-probe
: 42


--089e013cbd32dbab34052154b20f--