emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nathaniel Nicandro <nrn12@uic.edu>
To: org mode <emacs-orgmode@gnu.org>
Subject: [PATCH] Honor the :python header argument in python src-blocks
Date: Thu, 27 Apr 2017 19:04:25 -0500	[thread overview]
Message-ID: <m21ssdxura.fsf@uic.edu> (raw)

Hello,
 
This is my first post to the mailing list and I just wanted to say 
thank all of you for making such a great piece of code! 

Below is a patch that should fix the problem where a python session was
being initiated without first checking the :python header argument.

--- PATCH ---

From a721c97924b5b965179a2dd90e54d63c7de00317 Mon Sep 17 00:00:00 2001
From: Nathaniel Nicandro <nrn12@uic.edu>
Date: Thu, 27 Apr 2017 18:16:41 -0500
Subject: [PATCH] Honor the :python header argument in python src-blocks

* lisp/ob-python.el (org-babel-execute:python):
 `org-babel-python-command` should be set before calling
 `org-babel-python-initiate-session`.

TINYCHANGE
---
 lisp/ob-python.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index b838a48..f533658 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -73,15 +73,15 @@ This will typically be either `python' or `python-mode'."
 (defun org-babel-execute:python (body params)
   "Execute a block of Python code with Babel.
 This function is called by `org-babel-execute-src-block'."
-  (let* ((session (org-babel-python-initiate-session
+  (let* ((org-babel-python-command
+          (or (cdr (assq :python params)) org-babel-python-command))
+         (session (org-babel-python-initiate-session
           (cdr (assq :session params))))
          (result-params (cdr (assq :result-params params)))
          (result-type (cdr (assq :result-type params)))
          (return-val (when (and (eq result-type 'value) (not session))
                        (cdr (assq :return params))))
          (preamble (cdr (assq :preamble params)))
-         (org-babel-python-command
-          (or (cdr (assq :python params)) org-babel-python-command))
          (full-body
           (org-babel-expand-body:generic
           (concat body (if return-val (format "\nreturn %s" return-val) ""))
--
2.3.8

             reply	other threads:[~2017-04-28  0:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28  0:04 Nathaniel Nicandro [this message]
2017-04-29 14:28 ` [PATCH] Honor the :python header argument in python src-blocks Nicolas Goaziou

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=m21ssdxura.fsf@uic.edu \
    --to=nrn12@uic.edu \
    --cc=emacs-orgmode@gnu.org \
    /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).