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