Просмотр исходного кода

ob-python: Session returns empty string if no return value

* lisp/ob-python.el (org-babel-python--eval-ast): Change sessions to
return an empty string, instead of None, if there is no return value.
Jack Kamm 5 лет назад
Родитель
Сommit
5fc4576548
2 измененных файлов с 8 добавлено и 6 удалено
  1. 7 5
      etc/ORG-NEWS
  2. 1 1
      lisp/ob-python.el

+ 7 - 5
etc/ORG-NEWS

@@ -12,13 +12,15 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 
 * Version 9.4 (not yet released)
 ** Incompatible changes
-*** Python session return values must be top-level expression statements
+*** Change how Python sessions handle return values
 
 Python blocks with ~:session :results value~ header arguments now only
-return a value if the last line is a top-level expression statement,
-otherwise the result is None. Also, None will now show up under
-"#+RESULTS:", as it already did with ~:results value~ for non-session
-blocks.
+return a value if the last line is a top-level expression
+statement. If the last line is not a top-level expression statement,
+the block will return a blank (empty) result.
+
+Also, a return value of ~None~ will now show up under "#+RESULTS:", as
+it already did for non-session blocks.
 
 *** In HTML export, change on how outline-container-* is set
 

+ 1 - 1
lisp/ob-python.el

@@ -260,7 +260,7 @@ try:
             __org_babel_python_final.value), '<string>', 'eval'))
     else:
         exec(compile(__org_babel_python_ast, '<string>', 'exec'))
-        __org_babel_python_final = None
+        __org_babel_python_final = ''
 except Exception:
     from traceback import format_exc
     __org_babel_python_final = format_exc()