all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#50514: 28.0.50; org inline call to python src block req C-g to break
@ 2021-09-10 23:06 Barton, Mark
  2021-09-11 13:04 ` Lars Ingebrigtsen
  2021-09-11 13:26 ` Augusto Stoffel
  0 siblings, 2 replies; 28+ messages in thread
From: Barton, Mark @ 2021-09-10 23:06 UTC (permalink / raw)
  To: 50514

[-- Attachment #1: Type: text/plain, Size: 34149 bytes --]

With the Test.org<http://Test.org> file below, if I C-c C-c on the call_file_date it will echo “Shell native completion is enabled” and Emacs will not respond until I hit C-g. If I immediately C-c C-c again, it will echo “Inline error: multiline result cannot be used” and Emacs responds normally to commands without C-g to break out. The problem is only when I use session in the property line. If I comment out the property line then it works. My original file uses dozens of python src blocks that require the session option.

This all works fine if I replace python.el from commit 9c1bbad907, before the send string optimization, which is my current work around.
—begin test.org<http://test.org>---------

#+TITLE: Test Org Babel Export with Python Blocks
#+AUTHOR: Mark Barton
#+DATE: 2021-09-05
#+PROPERTY: header-args:python :session python-chain :exports results :results output


*** Initialize python

#+NAME: file_date
#+begin_src python :exports both
print("testing2", end="")
#+end_src

#+RESULTS: file_date
: >>> testing


*** Summary

Test inline call_file_date[:results output :results output]() {{{results(=testing2=)}}}

—end test.org<http://test.org>-------------






In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.6.0, NS appkit-2022.60 Version 11.5.1 (Build 20G80))
of 2021-09-10 built on C02FM1E2MD6T
Repository revision: dea67939b65f39b60d8e990745504bd8f9e3be2c
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.5.1

Configured using:
'configure --with-native-compilation'

Configured features:
ACL GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY
KQUEUE NS PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Org

Minor modes in effect:
  flyspell-mode: t
  org-indent-mode: t
  doom-modeline-mode: t
  company-quickhelp-mode: t
  company-quickhelp-local-mode: t
  org-super-agenda-mode: t
  org-bullets-mode: t
  global-atomic-chrome-edit-mode: t
  pcre-mode: t
  global-git-gutter-mode: t
  git-gutter-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  global-hungry-delete-mode: t
  hungry-delete-mode: t
  beacon-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-auto-revert-mode: t
  treemacs-filewatch-mode: t
  treemacs-follow-mode: t
  treemacs-git-mode: t
  treemacs-fringe-indicator-mode: t
  show-paren-mode: t
  show-smartparens-global-mode: t
  show-smartparens-mode: t
  smartparens-global-mode: t
  smartparens-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  which-key-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  shell-dirtrack-mode: t
  whole-line-or-region-global-mode: t
  whole-line-or-region-local-mode: t
  winner-mode: t
  global-so-long-mode: t
  delete-selection-mode: t
  global-company-mode: t
  company-mode: t
  marginalia-mode: t
  savehist-mode: t
  vertico-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  window-divider-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  visual-line-mode: t
  transient-mark-mode: t

Load-path shadows:
/Users/bartm002/.emacs.d/elpa/magit-20210910.1028/magit-section-pkg hides /Users/bartm002/.emacs.d/elpa/magit-section-20210829.1849/magit-section-pkg
/Users/bartm002/.emacs.d/elpa/transient-20210819.2118/transient hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/transient
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-stan hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-stan
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-exp hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-exp
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-J hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-J
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-emacs-lisp hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-emacs-lisp
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-css hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-css
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-lob hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-lob
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-irc hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-irc
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-forth hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-forth
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-macs hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-macs
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-version hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-version
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-scheme hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-scheme
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-abc hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-abc
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-C hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-C
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-capture hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-capture
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-ref hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-ref
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-clojure hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-clojure
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-mouse hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-mouse
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-ledger hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-ledger
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-ctags hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-ctags
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-entities hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-entities
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-archive hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-archive
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-screen hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-screen
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-bibtex hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-bibtex
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-haskell hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-haskell
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-asymptote hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-asymptote
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-table hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-table
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-eww hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-eww
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-org hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-org
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-num hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-num
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-plot hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-plot
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-rmail hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-rmail
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-awk hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-awk
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-groovy hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-groovy
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-octave hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-octave
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-faces hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-faces
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-colview hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-colview
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-R hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-R
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-refile hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-refile
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-timer hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-timer
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-ebnf hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-ebnf
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-mobile hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-mobile
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-fortran hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-fortran
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-shell hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-shell
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-perl hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-perl
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-sqlite hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-sqlite
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-sed hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-sed
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-list hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-list
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-ruby hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-ruby
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-eval hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-eval
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-habit hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-habit
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-clock hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-clock
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-goto hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-goto
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-html hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-html
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-src hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-src
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-lisp hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-lisp
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-eshell hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-eshell
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-ditaa hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-ditaa
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-pcomplete hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-pcomplete
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-lint hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-lint
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-latex hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-latex
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-sass hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-sass
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-io hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-io
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-tangle hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-tangle
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-calc hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-calc
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-java hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-java
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-icalendar hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-icalendar
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-mhe hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-mhe
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-attach-git hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-attach-git
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-md hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-md
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-beamer hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-beamer
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-element hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-element
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-protocol hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-protocol
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-mscgen hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-mscgen
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-gnuplot hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-gnuplot
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-tempo hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-tempo
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-latex hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-latex
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-w3m hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-w3m
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-id hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-id
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-vala hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-vala
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-man hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-man
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-feed hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-feed
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-lua hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-lua
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-table hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-table
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-ocaml hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-ocaml
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-coq hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-coq
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-gnus hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-gnus
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-picolisp hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-picolisp
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-indent hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-indent
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-lilypond hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-lilypond
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-matlab hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-matlab
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-datetree hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-datetree
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-docview hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-docview
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-python hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-python
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-makefile hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-makefile
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-duration hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-duration
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-agenda hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-agenda
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-dot hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-dot
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-js hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-js
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-publish hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-publish
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-inlinetask hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-inlinetask
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-org hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-org
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-keys hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-keys
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-core hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-core
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-compat hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-compat
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-odt hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-odt
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-info hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-info
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-plantuml hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-plantuml
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-eshell hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-eshell
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-ascii hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-ascii
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-loaddefs hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-loaddefs
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-hledger hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-hledger
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-maxima hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-maxima
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ol-bbdb hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ol-bbdb
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-macro hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-macro
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-sql hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-sql
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-attach hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-attach
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-processing hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-processing
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ox-texinfo hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ox-texinfo
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-crypt hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-crypt
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-footnote hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-footnote
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/org-install hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/org-install
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-comint hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-comint
/Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210906/ob-shen hides /Users/bartm002/Documents/GitHub/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/ob-shen

Features:
(shadow sort mail-extr emacsbug sendmail lsp-zig lsp-steep lsp-svelte
lsp-sqls lsp-yaml lsp-xml lsp-vimscript lsp-vhdl lsp-vetur lsp-html
lsp-verilog lsp-vala lsp-v lsp-terraform lsp-tex lsp-sorbet
lsp-solargraph lsp-rust lsp-rf lsp-r lsp-purescript lsp-pylsp lsp-pyls
lsp-pwsh lsp-php lsp-perl lsp-ocaml lsp-nix lsp-nim lsp-markdown lsp-lua
lsp-kotlin lsp-json lsp-javascript lsp-haxe lsp-groovy lsp-hack
lsp-graphql lsp-go lsp-completion lsp-gdscript lsp-fsharp lsp-fortran
lsp-eslint lsp-erlang lsp-elixir lsp-elm lsp-dockerfile lsp-dhall lsp-d
lsp-css lsp-csharp gnutls lsp-crystal lsp-cmake lsp-clojure
lsp-semantic-tokens lsp-clangd lsp-beancount lsp-bash lsp-angular
lsp-ada lsp-actionscript flyspell ispell org-indent ol-eww ol-rmail
ol-mhe ol-irc ol-info ol-gnus nnselect gnus-search eieio-opt speedbar
ezimage dframe gnus-art mm-uu mml2015 mm-view mml-smime smime dig
gnus-sum gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud nnimap
nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range
gnus-win ol-docview doc-view ol-bibtex bibtex ol-bbdb ol-w3m vc-mtn
vc-hg vc-bzr vc-src vc-sccs vc-cvs vc-rcs cursor-sensor
rainbow-delimiters display-line-numbers doom-modeline
doom-modeline-segments doom-modeline-env doom-modeline-core shrink-path
company-quickhelp ein ox-pandoc ox-org org-mouse ob-plantuml ob-latex
ob-org ob-dot ob-ditaa ob-js ob-C ob-shell ob-python python-pytest
smartparens-python python ob-sql-mode ob-sql org-crypt org-web-tools eww
xdg url-queue shr kinsoku svg mm-url gnus nnheader esxml-query dom
org-omnifocus org-devonthink org-sidebar org-ql-search org-ql-view ov
org-super-agenda org-ql peg ts org-habit dash-functional ox-clip htmlize
org-pomodoro alert log4e notifications dbus gntp org-timer org-clock
org-bullets org-eldoc ox-extra ox-odt rng-loc rng-uri rng-parse
rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok
nxml-util ox-latex ox-icalendar ox-html table ox-ascii ox-publish ox
org-protocol iedit iedit-lib pdf-tools pdf-view jka-compr pdf-cache
pdf-info tq pdf-util pdf-macs image-mode exif all-the-icons
all-the-icons-faces data-material data-weathericons data-octicons
data-fileicons data-faicons data-alltheicons sdcv pos-tip showtip
synosaurus ido dictionary dictionary-connection atomic-chrome websocket
bindat let-alist visual-regexp regex-tool pcre2el rxt re-builder rg
rg-info-hack rg-menu rg-ibuffer rg-result wgrep-rg rg-history rg-header
ag vc-svn find-dired wgrep-ag wgrep bufler projectile grep ibuf-ext
ibuffer ibuffer-loaddefs pretty-hydra hydra bufler-group-tree dumb-jump
popup vterm face-remap term disp-table ehelp vterm-module term/xterm
xterm magit-lfs git-timemachine vc-git git-gutter magit-bookmark
magit-submodule magit-obsolete magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func magit-diff
smerge-mode diff-mode git-commit log-edit message rfc822 mml mml-sec epa
gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mailabbrev
gmm-utils pcvs-util add-log magit-core magit-autorevert magit-margin
magit-transient magit-process with-editor server magit-mode transient
magit-git magit-section magit-utils crm dired-subtree dired-narrow
dired-hacks-utils multiple-cursors mc-separate-operations
rectangular-region-mode mc-mark-pop mc-edit-lines
mc-hide-unmatched-lines-mode mc-mark-more mc-cycle-cursors
multiple-cursors-core rect hungry-delete beacon undo-tree diff
restclient dap-java lsp-java request mailheader autorevert mail-utils
lsp-treemacs lsp-treemacs-themes treemacs treemacs-header-line
treemacs-compatibility treemacs-mode treemacs-bookmarks
treemacs-interface treemacs-extensions treemacs-mouse-interface
treemacs-tags treemacs-persistence treemacs-filewatch-mode
treemacs-follow-mode treemacs-rendering treemacs-async
treemacs-workspaces treemacs-dom treemacs-visuals
treemacs-fringe-indicator treemacs-scope treemacs-faces treemacs-icons
treemacs-themes treemacs-core-utils pfuture treemacs-logging
treemacs-customization treemacs-macros smartparens-c cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
blacken pyvenv eshell esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg
esh-module esh-groups esh-util dap-lldb dap-python dap-mode dap-launch
posframe dap-overlays lsp-pyright lsp-sourcekit lsp lsp-mode
lsp-protocol tree-widget network-stream puny nsm rmc
smartparens-markdown markdown-mode lv inline ht filenotify f ewoc epg
rfc6068 epg-config swift-mode swift-mode-imenu swift-mode-repl
swift-mode-beginning-of-defun swift-mode-font-lock
swift-mode-standard-types swift-mode-indent swift-mode-lexer
highlight-indent-guides smartparens-config smartparens-org
smartparens-text smartparens-clojure paren smartparens
use-package-diminish powershell flycheck-plantuml flycheck ace-window
avy transpose-frame which-key try yasnippet-classic-snippets
yasnippet-snippets yasnippet ejc-sql-conf ejc-company ejc-sql
ejc-completion-common ejc-doc ejc-eldoc ejc-direx ejc-interaction
clomacs simple-httpd net-utils ejc-format ejc-result-buffer
ejc-result-mode cua-base direx eieio-compat dired dired-loaddefs ejc-lib
s cider tramp-sh cider-debug cider-browse-ns cider-mode cider-find
cider-inspector cider-completion cider-profile cider-eval cider-jar
arc-mode archive-mode compile cider-repl-history pulse cider-repl
cider-resolve cider-test cider-overlays cider-stacktrace cider-doc
cider-browse-spec cider-clojuredocs cider-eldoc cider-client
cider-common cider-connection cider-util color cider-popup
sesman-browser nrepl-client tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat shell parse-time iso8601 ls-lisp
queue nrepl-dict cider-compat spinner sesman vc vc-dispatcher
clojure-mode lisp-mnt mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr align imenu parseedn parseclj-parser parseclj-lex
a derived sql view sqlformat reformatter unfill burly bookmark
text-property-search whole-line-or-region move-text wrap-region
default-text-scale zoom-window winner comp comp-cstr warnings so-long
hl-line delsel desktop frameset cus-edit pp cus-load wid-edit
plantuml-mode xml dash thingatpt company-oddmuse company-keywords
company-etags etags fileloop xref project company-gtags
company-dabbrev-code company-dabbrev company-files company-clang
company-capf company-cmake company-semantic company-template
company-bbdb company pcase exec-path-from-shell calfw-org org-capture
org-element avl-tree generator org-agenda org-refile calfw holidays
hol-loaddefs cl marginalia savehist orderless vertico
modus-vivendi-theme modus-operandi-theme modus-themes
use-package-bind-key bind-key use-package-ensure use-package-core
cl-extra help-mode org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint
ansi-color ring org-list org-faces org-entities time-date noutline
outline easy-mmode org-version ob-emacs-lisp ob-core ob-eval org-table
ol rx org-keys org-compat advice org-macs org-loaddefs format-spec
find-func cal-menu calendar cal-loaddefs finder-inf edmacro kmacro info
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads kqueue
cocoa ns lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 1143528 216646)
(symbols 48 77259 138)
(strings 32 322051 82623)
(string-bytes 1 11052667)
(vectors 16 133021)
(vector-slots 8 2544805 369169)
(floats 8 1255 1903)
(intervals 56 1666 1318)
(buffers 992 17))

[-- Attachment #2: Type: text/html, Size: 43193 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-10 23:06 bug#50514: 28.0.50; org inline call to python src block req C-g to break Barton, Mark
@ 2021-09-11 13:04 ` Lars Ingebrigtsen
  2021-09-11 13:26 ` Augusto Stoffel
  1 sibling, 0 replies; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-11 13:04 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514, Augusto Stoffel

"Barton, Mark" <Mark.Barton@disney.com> writes:

> With the Test.org file below, if I C-c C-c on the call_file_date it will echo
> “Shell native completion is enabled” and Emacs will not respond until I hit
> C-g. If I immediately C-c C-c again, it will echo “Inline error: multiline result
> cannot be used” and Emacs responds normally to commands without C-g to
> break out. The problem is only when I use session in the property line. If I
> comment out the property line then it works. My original file uses dozens of
> python src blocks that require the session option.
>
> This all works fine if I replace python.el from commit 9c1bbad907, before the
> send string optimization, which is my current work around.

Augusto, can you take a look at this bug report?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-10 23:06 bug#50514: 28.0.50; org inline call to python src block req C-g to break Barton, Mark
  2021-09-11 13:04 ` Lars Ingebrigtsen
@ 2021-09-11 13:26 ` Augusto Stoffel
  2021-09-12  6:22   ` Barton, Mark
  1 sibling, 1 reply; 28+ messages in thread
From: Augusto Stoffel @ 2021-09-11 13:26 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514, Lars Ingebrigtsen

[-- Attachment #1: Type: text/plain, Size: 784 bytes --]

On Fri, 10 Sep 2021 at 23:06, "Barton, Mark" <Mark.Barton@disney.com> wrote:

> With the Test.org file below, if I C-c C-c on the call_file_date it will echo “Shell native completion is
> enabled” and Emacs will not respond until I hit C-g. If I immediately C-c C-c again, it will echo
> “Inline error: multiline result cannot be used” and Emacs responds normally to commands
> without C-g to break out. The problem is only when I use session in the property line. If I comment
> out the property line then it works. My original file uses dozens of python src blocks that require
> the session

Hi Mark,

does the patch below solve the problem for you?

If it does, then I know why it happens and I can suggest the Org people
a slightly more robust solution.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ob-python.diff --]
[-- Type: text/x-patch, Size: 577 bytes --]

diff --git a/lisp/org/ob-python.el b/lisp/org/ob-python.el
index 7911205d08..e3714964b7 100644
--- a/lisp/org/ob-python.el
+++ b/lisp/org/ob-python.el
@@ -352,7 +352,7 @@ org-babel-python--send-string
 		   org-babel-python-eoe-indicator
 		   string-buffer))
 	(accept-process-output (get-buffer-process (current-buffer))))
-      (org-babel-chomp (substring string-buffer 0 (match-beginning 0))))))
+      (org-babel-chomp (substring string-buffer 1 (match-beginning 0))))))
 
 (defun org-babel-python-evaluate-session
     (session body &optional result-type result-params)

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-11 13:26 ` Augusto Stoffel
@ 2021-09-12  6:22   ` Barton, Mark
  2021-09-12  6:51     ` Augusto Stoffel
  0 siblings, 1 reply; 28+ messages in thread
From: Barton, Mark @ 2021-09-12  6:22 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen



> On Sep 11, 2021, at 6:26 AM, Augusto Stoffel <arstoffel@gmail.com> wrote:
> 
> On Fri, 10 Sep 2021 at 23:06, "Barton, Mark" <Mark.Barton@disney.com> wrote:
> 
>> With the Test.org file below, if I C-c C-c on the call_file_date it will echo “Shell native completion is
>> enabled” and Emacs will not respond until I hit C-g. If I immediately C-c C-c again, it will echo
>> “Inline error: multiline result cannot be used” and Emacs responds normally to commands
>> without C-g to break out. The problem is only when I use session in the property line. If I comment
>> out the property line then it works. My original file uses dozens of python src blocks that require
>> the session
> 
> Hi Mark,
> 
> does the patch below solve the problem for you?
> 
> If it does, then I know why it happens and I can suggest the Org people
> a slightly more robust solution.
> 
> <ob-python.diff>

Augusto,

I applied the patch to both lisp/org/ob-python.el and later ~/.emacs.d/elpa/org-plus-contrib-20210906 when I realized that is where my instance of org is loading from. I saw more python.el patches, so I pulled commit 108dbed4c0 from master to recompile.

I now get “Shell native completion is disabled, using fallback” in the echo area and need to press C-g to break. But now with the patch to ob-python.el it will work the following times when I press C-c on the call_file_date.

In my original document, I can export to pdf after I hit C-g to break out of the first session, try to export again and then hit C-g to break out of my second named python session, and then with both those python session buffers opened, the third attempt to export succeeds.

I suspect that in my case the initial setup code you send only once per python session is stuck which requires me to send a C-g, but since the session buffer is established, the setup code is not send again and it proceeds as expected.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-12  6:22   ` Barton, Mark
@ 2021-09-12  6:51     ` Augusto Stoffel
  2021-09-12  8:27       ` Barton, Mark
  0 siblings, 1 reply; 28+ messages in thread
From: Augusto Stoffel @ 2021-09-12  6:51 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen


Okay, I opened a bug in Org mode linking to this ticket and suggesting
the solution https://orgmode.org/list/875yv61ej9.fsf@gmail.com/T/#u

As to the problem still you have when starting up the shell, I can't
observe it (but I am not able to test on macos).  Does it happen when
you just call `M-x run-python' from emacs -Q?  And does it persist if you
do
  (setq python-shell-completion-native-enable nil)
?


On Sun, 12 Sep 2021 at 06:22, "Barton, Mark" <Mark.Barton@disney.com> wrote:

>> On Sep 11, 2021, at 6:26 AM, Augusto Stoffel <arstoffel@gmail.com> wrote:
>> 
>> On Fri, 10 Sep 2021 at 23:06, "Barton, Mark" <Mark.Barton@disney.com> wrote:
>> 
>>> With the Test.org file below, if I C-c C-c on the call_file_date it
>>> will echo “Shell native completion is
>>> enabled” and Emacs will not respond until I hit C-g. If I
>>> immediately C-c C-c again, it will echo
>>> “Inline error: multiline result cannot be used” and Emacs responds
>>> normally to commands
>>> without C-g to break out. The problem is only when I use session in
>>> the property line. If I comment
>>> out the property line then it works. My original file uses dozens
>>> of python src blocks that require
>>> the session
>> 
>> Hi Mark,
>> 
>> does the patch below solve the problem for you?
>> 
>> If it does, then I know why it happens and I can suggest the Org people
>> a slightly more robust solution.
>> 
>> <ob-python.diff>
>
> Augusto,
>
> I applied the patch to both lisp/org/ob-python.el and later
> ~/.emacs.d/elpa/org-plus-contrib-20210906 when I realized that is
> where my instance of org is loading from. I saw more python.el
> patches, so I pulled commit 108dbed4c0 from master to recompile.
>
> I now get “Shell native completion is disabled, using fallback” in the
> echo area and need to press C-g to break. But now with the patch to
> ob-python.el it will work the following times when I press C-c on the
> call_file_date.
>
> In my original document, I can export to pdf after I hit C-g to break
> out of the first session, try to export again and then hit C-g to
> break out of my second named python session, and then with both those
> python session buffers opened, the third attempt to export succeeds.
>
> I suspect that in my case the initial setup code you send only once
> per python session is stuck which requires me to send a C-g, but since
> the session buffer is established, the setup code is not send again
> and it proceeds as expected.
>
> Thanks,
>
> Mark





^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-12  6:51     ` Augusto Stoffel
@ 2021-09-12  8:27       ` Barton, Mark
  2021-09-12  9:15         ` Augusto Stoffel
  0 siblings, 1 reply; 28+ messages in thread
From: Barton, Mark @ 2021-09-12  8:27 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

[-- Attachment #1: Type: text/plain, Size: 2749 bytes --]



On Sep 11, 2021, at 11:51 PM, Augusto Stoffel <arstoffel@gmail.com<mailto:arstoffel@gmail.com>> wrote:


Okay, I opened a bug in Org mode linking to this ticket and suggesting
the solution https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Forgmode.org%2Flist%2F875yv61ej9.fsf%40gmail.com%2FT%2F%23u&amp;data=04%7C01%7CMark.Barton%40disney.com%7Cf0ed3506c5a84b98ec2408d975b9b53c%7C56b731a8a2ac4c32bf6b616810e913c6%7C1%7C0%7C637670262742236357%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=DH%2BaAGp7m%2BddApEMkeWBmAJ%2FXLIWxJy7oCVxG1oFItc%3D&amp;reserved=0

As to the problem still you have when starting up the shell, I can't
observe it (but I am not able to test on macos).  Does it happen when
you just call `M-x run-python' from emacs -Q?  And does it persist if you
do
 (setq python-shell-completion-native-enable nil)
?


Augusto,

If I  (setq python-shell-completion-native-enable nil) then I don’t get a message about the completion in the echo area, but I still need to do C-g to break out in order to send any commands (keystrokes) to emacs.

If I run emacs -Q and then open that org file and run M-x run-python. Then it opens Inferior Python in a buffer *Python* and emacs is responsive and so is the python shell. I noted earlier that if I don’t use the session naming, then simple cases work where I don’t need multiple src blocks to share an environment.

This time I tried setting “Enter Debugger on Quit/C-g” from the Option menu in Emacs. This is what I get when I pressed C-g to get control of Emacs after the first C-c C-c to evaluate call_file_date inline function.

Debugger entered--Lisp error: (quit)
  org-babel-python--send-string("*python-chain*" "with open('/var/folders/kf/zdpzgs9d30b3jj4bdkdjf1v...")
  org-babel-python-evaluate-session("*python-chain*" "print(\"testing2\", end=\"\")" output ("replace" "output"))
  org-babel-python-evaluate("*python-chain*" "print(\"testing2\", end=\"\")" output ("replace" "output") nil)
  org-babel-execute:python("print(\"testing2\", end=\"\")" ((:colname-names) (:rowname-names) (:result-params "replace" "output") (:result-type . output) (:results . "replace output") (:exports . "results") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "python-chain")))
  org-babel-execute-src-block(nil ("python" "print(\"testing2\", end=\"\")" ((:results . "output replace") (:exports . "results") (:session . "python-chain") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no")) nil nil 359 "(ref:%s)"))
  org-ctrl-c-ctrl-c(nil)
  funcall-interactively(org-ctrl-c-ctrl-c nil)
  command-execute(org-ctrl-c-ctrl-c)







[-- Attachment #2: Type: text/html, Size: 5281 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-12  8:27       ` Barton, Mark
@ 2021-09-12  9:15         ` Augusto Stoffel
  2021-09-12 17:00           ` Barton, Mark
  0 siblings, 1 reply; 28+ messages in thread
From: Augusto Stoffel @ 2021-09-12  9:15 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

What if you (setq comint-max-line-length 0)?

If that solves the problem, you could try to find the biggest value that
still works for you (256 or 512 would be probable candidates).

On Sun, 12 Sep 2021 at 08:27, "Barton, Mark" <Mark.Barton@disney.com> wrote:

>  On Sep 11, 2021, at 11:51 PM, Augusto Stoffel <arstoffel@gmail.com> wrote:
>
>  Okay, I opened a bug in Org mode linking to this ticket and suggesting
>  the solution
>  https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Forgmode.org%2Flist%2F875yv61ej9.fsf%40gmail.com%2FT%2F%23u&amp;data=04%7C01%7CMark.Barton%40disney.com%7Cf0ed3506c5a84b98ec2408d975b9b53c%7C56b731a8a2ac4c32bf6b616810e913c6%7C1%7C0%7C637670262742236357%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=DH%2BaAGp7m%2BddApEMkeWBmAJ%2FXLIWxJy7oCVxG1oFItc%3D&amp;reserved=0
>  
>
>  As to the problem still you have when starting up the shell, I can't
>  observe it (but I am not able to test on macos).  Does it happen when
>  you just call `M-x run-python' from emacs -Q?  And does it persist if you
>  do
>   (setq python-shell-completion-native-enable nil)
>  ?
>
> Augusto, 
>
> If I  (setq python-shell-completion-native-enable nil) then I don’t get a message about the
> completion in the echo area, but I still need to do C-g to break out in order to send any commands
> (keystrokes) to emacs. 
>
> If I run emacs -Q and then open that org file and run M-x run-python. Then it opens Inferior Python
> in a buffer *Python* and emacs is responsive and so is the python shell. I noted earlier that if I
> don’t use the session naming, then simple cases work where I don’t need multiple src blocks to
> share an environment.
>
> This time I tried setting “Enter Debugger on Quit/C-g” from the Option menu in Emacs. This is
> what I get when I pressed C-g to get control of Emacs after the first C-c C-c to evaluate
> call_file_date inline function.
>
> Debugger entered--Lisp error: (quit)
>   org-babel-python--send-string("*python-chain*" "with open
> ('/var/folders/kf/zdpzgs9d30b3jj4bdkdjf1v...")
>   org-babel-python-evaluate-session("*python-chain*" "print(\"testing2\", end=\"\")" output
> ("replace" "output"))
>   org-babel-python-evaluate("*python-chain*" "print(\"testing2\", end=\"\")" output ("replace"
> "output") nil)
>   org-babel-execute:python("print(\"testing2\", end=\"\")" ((:colname-names) (:rowname-names)
> (:result-params "replace" "output") (:result-type . output) (:results . "replace output") (:exports .
> "results") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "python-chain")))
>   org-babel-execute-src-block(nil ("python" "print(\"testing2\", end=\"\")" ((:results . "output
> replace") (:exports . "results") (:session . "python-chain") (:cache . "no") (:noweb . "no") (:hlines .
> "no") (:tangle . "no")) nil nil 359 "(ref:%s)"))
>   org-ctrl-c-ctrl-c(nil)
>   funcall-interactively(org-ctrl-c-ctrl-c nil)
>   command-execute(org-ctrl-c-ctrl-c)





^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-12  9:15         ` Augusto Stoffel
@ 2021-09-12 17:00           ` Barton, Mark
  2021-09-12 20:04             ` Barton, Mark
  0 siblings, 1 reply; 28+ messages in thread
From: Barton, Mark @ 2021-09-12 17:00 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen



> On Sep 12, 2021, at 2:15 AM, Augusto Stoffel <arstoffel@gmail.com> wrote:
> 
> What if you (setq comint-max-line-length 0)?
> 
> If that solves the problem, you could try to find the biggest value that
> still works for you (256 or 512 would be probable candidates).
> 

I tried setting it to zero and I got the same results where I need to use C-g the first time for that python session buffer and then subsequent evaluations of python using that already established session via the named session src block header work as expected. Just in case 0 meant no limit to the max length, I also tried setting it to 1 and got the same results.

I will see if I can learn how to trace the execution on my system to determine what is different between the first evaluation and then the working subsequent ones.




^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-12 17:00           ` Barton, Mark
@ 2021-09-12 20:04             ` Barton, Mark
  2021-09-14  6:42               ` Augusto Stoffel
  0 siblings, 1 reply; 28+ messages in thread
From: Barton, Mark @ 2021-09-12 20:04 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

[-- Attachment #1: Type: text/plain, Size: 4516 bytes --]

If I create the comint buffer myself and then make that inline python function call in the org document, then it works. Below is the lisp I evaluated to make the comint buffer myself based on what I saw in the Backtraces.
(python-shell-make-comint "python" "python-chain" nil)

Here is the Backtrace where I tried to compare what happens when I need to press C-g.
#+begin_example C-c C-c needs to make comint shell
Debugger entered--returning value: 0
  alist-get(yas--post-command-handler ((python-shell-font-lock-post-command-hook . 0) (yas--post-command-handler . 0) (company-post-command . 0) (company-post-command . 0) (yas--post-command-handler . 0) (vertico--exhibit . -90) (consult--preview-post-command . 0) (vertico--exhibit . -90) (eldoc-schedule-timer . 0) (eldoc-schedule-timer . 0) (eldoc-schedule-timer . 0) (eldoc-schedule-timer . 0) (eldoc-schedule-timer . 0) (python-shell-font-lock-post-command-hook . 0) (jit-lock--antiblink-post-command . 0) (company-post-command . 0) (company-post-command . 0) (yas--post-command-handler . 0) (yas--post-command-handler . 0) (company-post-command . 0) (yas--post-command-handler . 0) (vertico--exhibit . -90) (vertico--exhibit . -90) (consult--preview-post-command . 0) (vertico--exhibit . -90) (vertico--exhibit . -90) (consult--preview-post-command . 0) (vertico--exhibit . -90) (vertico--exhibit . -90) (company-post-command . 0) (yas--post-command-handler . 0) (hl-line-highlight . 0) (magit-section-update-highlight . 90) (vertico--exhibit . -90) (vertico--exhibit . -90) (company-post-command . 0) (yas--post-command-handler . 0) (magit-section-update-highlight . 90) (consult--preview-post-command . 0) (vertico--exhibit . -90) (company-post-command . 0) (yas--post-command-handler . 0) (magit-section-update-highlight . 90) (company-post-command . 0) (yas--post-command-handler . 0) (magit-section-update-highlight . 90) (vertico--exhibit . -90) (consult--preview-post-command . 0) (vertico--exhibit . -90) (eldoc-schedule-timer . 0) ...) 0 nil eq)
,* #f(compiled-function (f1 f2) #<bytecode -0x6149ed0fee718f2>)(yas--post-command-handler python-shell-font-lock-post-command-hook)
,* add-hook(post-command-hook python-shell-font-lock-post-command-hook nil local)
  python-shell-font-lock-turn-on()
  inferior-python-mode()
  python-shell-make-comint("python" "python-chain" nil)
  run-python("python")
  org-babel-python-initiate-session-by-key("python-chain")
  org-babel-python-initiate-session("python-chain")
  org-babel-execute:python("print(\"testing12\", end=\"\")" ((:colname-names) (:rowname-names) (:result-params "replace" "output") (:result-type . output) (:results . "replace output") (:exports . "results") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "python-chain")))
  org-babel-execute-src-block(nil ("python" "print(\"testing12\", end=\"\")" ((:results . "output replace") (:exports . "results") (:session . "python-chain") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no")) nil nil 360 "(ref:%s)"))
  org-ctrl-c-ctrl-c(nil)
  funcall-interactively(org-ctrl-c-ctrl-c nil)
  command-execute(org-ctrl-c-ctrl-c)

#+end_example

#+begin_example comint shell already exists
Debugger entered--entering a function:
,* comint-snapshot-last-prompt()
,* comint-send-string(#<process python-chain> "__PYTHON_EL_eval(\"try:\\n    with open('/var/folder...")
  python-shell-send-string("try:\n    with open('/var/folders/kf/zdpzgs9d30b3jj...")
  org-babel-python--send-string("*python-chain*" "with open('/var/folders/kf/zdpzgs9d30b3jj4bdkdjf1v...")
  org-babel-python-evaluate-session("*python-chain*" "print(\"testing12\", end=\"\")" output ("replace" "output"))
  org-babel-python-evaluate("*python-chain*" "print(\"testing12\", end=\"\")" output ("replace" "output") nil)
  org-babel-execute:python("print(\"testing12\", end=\"\")" ((:colname-names) (:rowname-names) (:result-params "replace" "output") (:result-type . output) (:results . "replace output") (:exports . "results") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "python-chain")))
  org-babel-execute-src-block(nil ("python" "print(\"testing12\", end=\"\")" ((:results . "output replace") (:exports . "results") (:session . "python-chain") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no")) nil nil 360 "(ref:%s)"))
  org-ctrl-c-ctrl-c(nil)
  funcall-interactively(org-ctrl-c-ctrl-c nil)
  command-execute(org-ctrl-c-ctrl-c)

#+end_example



[-- Attachment #2: Type: text/html, Size: 6681 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-12 20:04             ` Barton, Mark
@ 2021-09-14  6:42               ` Augusto Stoffel
  2021-09-14 17:54                 ` Barton, Mark
  0 siblings, 1 reply; 28+ messages in thread
From: Augusto Stoffel @ 2021-09-14  6:42 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

[-- Attachment #1: Type: text/plain, Size: 576 bytes --]

Hi Mark,

After removing the patch to ob-python.el and applying the attached patch
to python.el, could you please test that your notebooks work again?

This will probably not change the independent initialization problem
that you describe (but it might, who knows).  If you want to help me
understanding that part, you can do

  M-x trace-function RET python-shell-send-string-no-output
  M-x trace-function RET python-shell-output-filter-buffer
  M-x trace-function RET python-shell-completion-native-get-completions

and send the result printed to 'trace-buffer'.  Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Python-shell-rearrange-printing-of-newline-before-ou.patch --]
[-- Type: text/x-patch, Size: 2550 bytes --]

From 096a3cb45baa4ff954c19c1d2d34dd86757ef4f5 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Tue, 14 Sep 2021 05:31:45 +0200
Subject: [PATCH] Python shell: rearrange printing of newline before output

* progmodes/python.el (python-shell-output-filter-in-progress,
python-shell-output-filter-buffer): Move defvars to avoid compiler
warnings.
(python-shell-eval-setup-code): Don't print a
newline in __PYTHON_EL_eval.
(python-shell-send-string): Insert newline before output when
applicable,
---
 lisp/progmodes/python.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d9fc5c5009..fae350dea2 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2189,6 +2189,9 @@ python-shell-compilation-regexp-alist
   :type '(alist regexp)
   :group 'python)
 
+(defvar python-shell-output-filter-in-progress nil)
+(defvar python-shell-output-filter-buffer nil)
+
 (defmacro python-shell--add-to-path-with-priority (pathvar paths)
   "Modify PATHVAR and ensure PATHS are added only once at beginning."
   `(dolist (path (reverse ,paths))
@@ -2821,7 +2824,6 @@ python-shell-eval-setup-code
         from __builtin__ import compile, eval, globals
     else:
         from builtins import compile, eval, globals
-    sys.stdout.write('\\n')
     try:
         p, e = ast.parse(source, filename), None
     except SyntaxError:
@@ -3162,6 +3164,11 @@ python-shell-send-string
                       (python-shell--encode-string string)
                       (python-shell--encode-string (or (buffer-file-name)
                                                        "<string>")))))
+    (unless python-shell-output-filter-in-progress
+      (with-current-buffer (process-buffer process)
+        (save-excursion
+          (goto-char (process-mark process))
+          (insert-before-markers "\n"))))
     (if (or (null (process-tty-name process))
             (<= (string-bytes code)
                 (or (bound-and-true-p comint-max-line-length)
@@ -3172,9 +3179,6 @@ python-shell-send-string
              (file-name (or (buffer-file-name) temp-file-name)))
         (python-shell-send-file file-name process temp-file-name t)))))
 
-(defvar python-shell-output-filter-in-progress nil)
-(defvar python-shell-output-filter-buffer nil)
-
 (defun python-shell-output-filter (string)
   "Filter used in `python-shell-send-string-no-output' to grab output.
 STRING is the output received to this point from the process.
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-14  6:42               ` Augusto Stoffel
@ 2021-09-14 17:54                 ` Barton, Mark
  2021-09-14 18:29                   ` Augusto Stoffel
  0 siblings, 1 reply; 28+ messages in thread
From: Barton, Mark @ 2021-09-14 17:54 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

[-- Attachment #1: Type: text/plain, Size: 4532 bytes --]



On Sep 13, 2021, at 11:42 PM, Augusto Stoffel <arstoffel@gmail.com<mailto:arstoffel@gmail.com>> wrote:

Hi Mark,

After removing the patch to ob-python.el and applying the attached patch
to python.el, could you please test that your notebooks work again?

This will probably not change the independent initialization problem
that you describe (but it might, who knows).  If you want to help me
understanding that part, you can do

 M-x trace-function RET python-shell-send-string-no-output
 M-x trace-function RET python-shell-output-filter-buffer
 M-x trace-function RET python-shell-completion-native-get-completions

and send the result printed to 'trace-buffer'.  Thanks!

<0001-Python-shell-rearrange-printing-of-newline-before-ou.patch>

That patch fixes the multiline result error for me with the unpatched ob-python.el. I noticed yesterday the command in the tmp file was prefixed with \n and now with the patch it is not and org babel processes it fine as an inline function call to add the result within the text of the document.

I was not able to find python-shell-output-filter-buffer to trace so I substituted python-shell-output-filter. Here is the trace-output for my initial C-c C-c on the call inline function. As you suspected the initialization problem is still there for me, but perhaps this will shed some light on that. Below this is the trace for the second and successful call to the inline function.

#+begin_example Trace from initial execution that requires C-g to break
======================================================================
1 -> (python-shell-send-string-no-output "def __PYTHON_EL_eval(source, filename):
    import ast, sys
    if sys.version_info[0] == 2:
        from __builtin__ import compile, eval, globals
    else:
        from builtins import compile, eval, globals
    try:
        p, e = ast.parse(source, filename), None
    except SyntaxError:
        t, v, tb = sys.exc_info()
        sys.excepthook(t, v, tb.tb_next)
        return
    if p.body and isinstance(p.body[-1], ast.Expr):
        e = p.body.pop()
    try:
        g = globals()
        exec(compile(p, filename, 'exec'), g, g)
        if e:
            return eval(compile(ast.Expression(e.value), filename, 'eval'), g, g)
    except Exception:
        t, v, tb = sys.exc_info()
        sys.excepthook(t, v, tb.tb_next)")
| 2 -> (python-shell-output-filter "Traceback (most recent call last):
  File \"<stdin>\", line 1, in <module>
NameError: name '__PYTHON_EL_eval' is not defined
")
| 2 <- python-shell-output-filter: ""
| 2 -> (python-shell-output-filter ">>> ")
| 2 <- python-shell-output-filter: ""
1 <- python-shell-send-string-no-output: "Traceback (most recent call last):
  File \"<stdin>\", line 1, in <module>
NameError: name '__PYTHON_EL_eval' is not defined"
======================================================================
1 -> (python-shell-send-string-no-output "def __PYTHON_EL_eval_file(filename, tempname, delete):
    import codecs, os, re
    pattern = r'^[ ]*#.*?coding[:=][ ]*([-_.a-zA-Z0-9]+)'
    with codecs.open(tempname or filename, encoding='latin-1') as file:
        match = re.match(pattern, file.readline())
        match = match or re.match(pattern, file.readline())
        encoding = match.group(1) if match else 'utf-8'
    with codecs.open(tempname or filename, encoding=encoding) as file:
        source = file.read().encode(encoding)
    if delete and tempname:
        os.remove(tempname)
    return __PYTHON_EL_eval(source, filename)")
| 2 -> (python-shell-output-filter ">>> ")
| 2 <- python-shell-output-filter: ""
1 <- python-shell-send-string-no-output: ""
#+end_example

There was nothing showing up in the trace, until I added the python-shell-send-string to the list of trace functions.
#+begin_example Existing Python session and now works without the ob-python.el patch that modified chomp value
======================================================================
1 -> (python-shell-send-string "try:
    with open('/var/folders/kf/zdpzgs9d30b3jj4bdkdjf1vw0000gn/T/babel-eaPALH/python-ca4zF3') as __org_babel_python_tmpfile:
        exec(compile(__org_babel_python_tmpfile.read(), __org_babel_python_tmpfile.name, 'exec'))
except:
    raise
finally:
    print('org_babel_python_eoe')")
1 <- python-shell-send-string: nil
#+end_example

FYI the contents of that tmp file is:
#+begin_example Tmp file contents
print("testing23", end=“")
#+end_example

[-- Attachment #2: Type: text/html, Size: 10613 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-14 17:54                 ` Barton, Mark
@ 2021-09-14 18:29                   ` Augusto Stoffel
  2021-09-14 19:25                     ` Barton, Mark
  0 siblings, 1 reply; 28+ messages in thread
From: Augusto Stoffel @ 2021-09-14 18:29 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

Hi Mark,

thanks for testing.

What happens if you start Emacs, then do 'M-x run-python', then 'M-x
rename-buffer' to rename the Python shell as '*python-chain*', and then
execute your notebook as usual?

If this works, then the problem is in how ob-python initializes the
shell.  The Python shell needs a fraction of a second to start up, and
if you send stuff to it before it's ready, it can be cause problems.





^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-14 18:29                   ` Augusto Stoffel
@ 2021-09-14 19:25                     ` Barton, Mark
  2021-09-14 19:31                       ` Augusto Stoffel
  2021-09-14 19:36                       ` Augusto Stoffel
  0 siblings, 2 replies; 28+ messages in thread
From: Barton, Mark @ 2021-09-14 19:25 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]



On Sep 14, 2021, at 11:29 AM, Augusto Stoffel <arstoffel@gmail.com<mailto:arstoffel@gmail.com>> wrote:

Hi Mark,

thanks for testing.

What happens if you start Emacs, then do 'M-x run-python', then 'M-x
rename-buffer' to rename the Python shell as '*python-chain*', and then
execute your notebook as usual?

If this works, then the problem is in how ob-python initializes the
shell.  The Python shell needs a fraction of a second to start up, and
if you send stuff to it before it's ready, it can be cause problems.

Augusto,

It runs as expected if I do that.

As a summary of what I have tried that works is:

- If I create the python buffer with this evaluation before running the org file/notebook.
(python-shell-make-comint "python" "python-chain" nil)

- If I don’t use the session header property to enable multiple src blocks to share the python session.

- If I revert back to the python.el on August 27th.
Possibly the older python.el was slow enough where I did not experience this problem.

Thanks for introducing me to the trace-function. I will try that with the org babel functions to see if I can learn something more about the initialization process.


[-- Attachment #2: Type: text/html, Size: 2354 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-14 19:25                     ` Barton, Mark
@ 2021-09-14 19:31                       ` Augusto Stoffel
  2021-09-14 22:20                         ` Barton, Mark
  2021-09-14 19:36                       ` Augusto Stoffel
  1 sibling, 1 reply; 28+ messages in thread
From: Augusto Stoffel @ 2021-09-14 19:31 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

Great.  Then we'll fix the spurious line break problem, which is indeed
on the Emacs side.  But the other is due to ob-python, which may send
code to the interpreter before the first prompt is printed (this can be
checked through the variable 'python-shell--first-prompt-received').

Since I don't use org-babel, I'm afraid I can't help with that part...





^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-14 19:25                     ` Barton, Mark
  2021-09-14 19:31                       ` Augusto Stoffel
@ 2021-09-14 19:36                       ` Augusto Stoffel
  2021-09-15  8:02                         ` Lars Ingebrigtsen
  1 sibling, 1 reply; 28+ messages in thread
From: Augusto Stoffel @ 2021-09-14 19:36 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Barton, Mark, 50514@debbugs.gnu.org

[-- Attachment #1: Type: text/plain, Size: 248 bytes --]

Lars, can you install the attached patch, which solves the parts of this
issue which originate in my recent changes?  The patch also does the
correct thing w.r.t. the text fields in the comint, something I was
unaware of until yesterday.

Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Python-shell-rearrange-printing-of-newline-before-ou.patch --]
[-- Type: text/x-patch, Size: 2550 bytes --]

From 096a3cb45baa4ff954c19c1d2d34dd86757ef4f5 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Tue, 14 Sep 2021 05:31:45 +0200
Subject: [PATCH] Python shell: rearrange printing of newline before output

* progmodes/python.el (python-shell-output-filter-in-progress,
python-shell-output-filter-buffer): Move defvars to avoid compiler
warnings.
(python-shell-eval-setup-code): Don't print a
newline in __PYTHON_EL_eval.
(python-shell-send-string): Insert newline before output when
applicable,
---
 lisp/progmodes/python.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d9fc5c5009..fae350dea2 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2189,6 +2189,9 @@ python-shell-compilation-regexp-alist
   :type '(alist regexp)
   :group 'python)
 
+(defvar python-shell-output-filter-in-progress nil)
+(defvar python-shell-output-filter-buffer nil)
+
 (defmacro python-shell--add-to-path-with-priority (pathvar paths)
   "Modify PATHVAR and ensure PATHS are added only once at beginning."
   `(dolist (path (reverse ,paths))
@@ -2821,7 +2824,6 @@ python-shell-eval-setup-code
         from __builtin__ import compile, eval, globals
     else:
         from builtins import compile, eval, globals
-    sys.stdout.write('\\n')
     try:
         p, e = ast.parse(source, filename), None
     except SyntaxError:
@@ -3162,6 +3164,11 @@ python-shell-send-string
                       (python-shell--encode-string string)
                       (python-shell--encode-string (or (buffer-file-name)
                                                        "<string>")))))
+    (unless python-shell-output-filter-in-progress
+      (with-current-buffer (process-buffer process)
+        (save-excursion
+          (goto-char (process-mark process))
+          (insert-before-markers "\n"))))
     (if (or (null (process-tty-name process))
             (<= (string-bytes code)
                 (or (bound-and-true-p comint-max-line-length)
@@ -3172,9 +3179,6 @@ python-shell-send-string
              (file-name (or (buffer-file-name) temp-file-name)))
         (python-shell-send-file file-name process temp-file-name t)))))
 
-(defvar python-shell-output-filter-in-progress nil)
-(defvar python-shell-output-filter-buffer nil)
-
 (defun python-shell-output-filter (string)
   "Filter used in `python-shell-send-string-no-output' to grab output.
 STRING is the output received to this point from the process.
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-14 19:31                       ` Augusto Stoffel
@ 2021-09-14 22:20                         ` Barton, Mark
  2021-09-15  6:28                           ` Augusto Stoffel
  0 siblings, 1 reply; 28+ messages in thread
From: Barton, Mark @ 2021-09-14 22:20 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

[-- Attachment #1: Type: text/plain, Size: 1562 bytes --]



On Sep 14, 2021, at 12:31 PM, Augusto Stoffel <arstoffel@gmail.com<mailto:arstoffel@gmail.com>> wrote:

Great.  Then we'll fix the spurious line break problem, which is indeed
on the Emacs side.  But the other is due to ob-python, which may send
code to the interpreter before the first prompt is printed (this can be
checked through the variable 'python-shell--first-prompt-received').

Since I don't use org-babel, I'm afraid I can't help with that part…

So I found if I extend the sleep-for in ob-python from 10 ms to 90 ms, my initialization problem is “fixed”. I’m not sure why it would take longer than it did before the changes. Possibly an interaction with the antivirus software??? I have not tried other values, but may be there is a better method for ob-python to determine it is safe than using a sleep-for.

diff -u --label /Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210913/ob-python.el --label \#\<buffer\ ob-python.el\> /Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210913/ob-python.el /var/folders/kf/zdpzgs9d30b3jj4bdkdjf1vw0000gn/T/buffer-content-Kqgm3d
--- /Users/bartm002/.emacs.d/elpa/org-plus-contrib-20210913/ob-python.el
+++ #<buffer ob-python.el>
@@ -193,7 +193,7 @@
  (let ((python-shell-buffer-name
        (org-babel-python-without-earmuffs py-buffer)))
   (run-python cmd)
-  (sleep-for 0 10)))
+  (sleep-for 0 90)))
        ((and (eq 'python-mode org-babel-python-mode)
      (fboundp 'py-shell)) ; python-mode.el
  (require 'python-mode)

Diff finished.  Tue Sep 14 15:14:59 2021



[-- Attachment #2: Type: text/html, Size: 3679 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-14 22:20                         ` Barton, Mark
@ 2021-09-15  6:28                           ` Augusto Stoffel
  0 siblings, 0 replies; 28+ messages in thread
From: Augusto Stoffel @ 2021-09-15  6:28 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen

On Tue, 14 Sep 2021 at 22:20, "Barton, Mark" <Mark.Barton@disney.com> wrote:

>  On Sep 14, 2021, at 12:31 PM, Augusto Stoffel <arstoffel@gmail.com> wrote:
>
>  Great.  Then we'll fix the spurious line break problem, which is indeed
>  on the Emacs side.  But the other is due to ob-python, which may send
>  code to the interpreter before the first prompt is printed (this can be
>  checked through the variable 'python-shell--first-prompt-received').
>
>  Since I don't use org-babel, I'm afraid I can't help with that part…
>
> So I found if I extend the sleep-for in ob-python from 10 ms to 90 ms, my initialization problem is
> “fixed”. I’m not sure why it would take longer than it did before the changes. Possibly an
> interaction with the antivirus software???

This was probably a problem all along, but went unnoticed until now
because 'python-shell-send-string' used to be simpler.

> I have not tried other values, but may be there is a better
> method for ob-python to determine it is safe than using a sleep-for.

One thing that might work is to block until the shell is ready with something like

    (run-python)
    (with-current-buffer *the-shell-buffer*
      (while (not python-shell--first-prompt-received)
        (accept-process-output (get-buffer-process (current-buffer)))))







^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-14 19:36                       ` Augusto Stoffel
@ 2021-09-15  8:02                         ` Lars Ingebrigtsen
  2022-08-25 15:12                           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-15  8:02 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Barton, Mark, 50514@debbugs.gnu.org

Augusto Stoffel <arstoffel@gmail.com> writes:

> Lars, can you install the attached patch, which solves the parts of this
> issue which originate in my recent changes?  The patch also does the
> correct thing w.r.t. the text fields in the comint, something I was
> unaware of until yesterday.

Yup; pushed to Emacs 28 now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2021-09-15  8:02                         ` Lars Ingebrigtsen
@ 2022-08-25 15:12                           ` Lars Ingebrigtsen
  2022-08-26 13:30                             ` Ihor Radchenko
  0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-25 15:12 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Barton, Mark, 50514@debbugs.gnu.org

The bug on the Emacs side was fixed by Augusto's patch, I think, but
there's a remaining problem in ob-python, so I'm reassigning this bug
report to org-mode.





^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2022-08-25 15:12                           ` Lars Ingebrigtsen
@ 2022-08-26 13:30                             ` Ihor Radchenko
  2022-08-27 13:16                               ` Lars Ingebrigtsen
  0 siblings, 1 reply; 28+ messages in thread
From: Ihor Radchenko @ 2022-08-26 13:30 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Barton, Mark, 50514@debbugs.gnu.org, Augusto Stoffel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> The bug on the Emacs side was fixed by Augusto's patch, I think, but
> there's a remaining problem in ob-python, so I'm reassigning this bug
> report to org-mode.

Could you please elaborate what the problem is?
There have been multiple issues in this thread and the one previously
reported to Org ML is solved on Emacs side.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2022-08-26 13:30                             ` Ihor Radchenko
@ 2022-08-27 13:16                               ` Lars Ingebrigtsen
  2022-08-27 14:11                                 ` Ihor Radchenko
  0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-27 13:16 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Barton, Mark, 50514@debbugs.gnu.org, Augusto Stoffel

Ihor Radchenko <yantar92@gmail.com> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> The bug on the Emacs side was fixed by Augusto's patch, I think, but
>> there's a remaining problem in ob-python, so I'm reassigning this bug
>> report to org-mode.
>
> Could you please elaborate what the problem is?
> There have been multiple issues in this thread and the one previously
> reported to Org ML is solved on Emacs side.

It's this bit:

> So I found if I extend the sleep-for in ob-python from 10 ms to 90 ms,
> my initialization problem is “fixed”.

The sleep is still 10ms in the in-tree ob-python, at least.





^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2022-08-27 13:16                               ` Lars Ingebrigtsen
@ 2022-08-27 14:11                                 ` Ihor Radchenko
  2022-08-27 18:56                                   ` Barton, Mark
  0 siblings, 1 reply; 28+ messages in thread
From: Ihor Radchenko @ 2022-08-27 14:11 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Barton, Mark, 50514@debbugs.gnu.org, Augusto Stoffel

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

>> Could you please elaborate what the problem is?
>> There have been multiple issues in this thread and the one previously
>> reported to Org ML is solved on Emacs side.
>
> It's this bit:
>
>> So I found if I extend the sleep-for in ob-python from 10 ms to 90 ms,
>> my initialization problem is “fixed”.
>
> The sleep is still 10ms in the in-tree ob-python, at least.

10ms magic constant is indeed not great.
However, I am unable to reproduce the original bug on my system.
I tried to draft an alternative patch. See the attached.

Mark, would you mind testing the patch?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-python-Fix-Emacs-bug-50514-when-Python-loads-slow.patch --]
[-- Type: text/x-patch, Size: 1820 bytes --]

From d5347c688d2fb8037116d82fa7987e9e6690ae66 Mon Sep 17 00:00:00 2001
Message-Id: <d5347c688d2fb8037116d82fa7987e9e6690ae66.1661609451.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 27 Aug 2022 22:06:11 +0800
Subject: [PATCH] ob-python: Fix Emacs bug#50514 when Python loads slowly

* lisp/ob-python.el (org-babel-python-initiate-session): Wait until
python process is initialized.
(org-babel-python-initiate-session-by-key): Do not rely on 10ms delay
to initialize Python.
---
 lisp/ob-python.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 932aca08e..2ad907bd8 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -197,8 +197,7 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
 	  (setq py-buffer (org-babel-python-with-earmuffs session)))
 	(let ((python-shell-buffer-name
 	       (org-babel-python-without-earmuffs py-buffer)))
-	  (run-python cmd)
-	  (sleep-for 0 10)))
+	  (run-python cmd)))
        ((and (eq 'python-mode org-babel-python-mode)
 	     (fboundp 'py-shell)) ; python-mode.el
 	(require 'python-mode)
@@ -225,8 +224,9 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
 (defun org-babel-python-initiate-session (&optional session _params)
   "Create a session named SESSION according to PARAMS."
   (unless (string= session "none")
-    (org-babel-python-session-buffer
-     (org-babel-python-initiate-session-by-key session))))
+    (let ((session (org-babel-python-session-buffer
+                    (org-babel-python-initiate-session-by-key session)))))
+    (org-babel-comint-wait-for-output session)))
 
 (defvar org-babel-python-eoe-indicator "org_babel_python_eoe"
   "A string to indicate that evaluation has completed.")
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2022-08-27 14:11                                 ` Ihor Radchenko
@ 2022-08-27 18:56                                   ` Barton, Mark
  2022-08-27 21:31                                     ` Mark Barton
  0 siblings, 1 reply; 28+ messages in thread
From: Barton, Mark @ 2022-08-27 18:56 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen, Augusto Stoffel

[-- Attachment #1: Type: text/plain, Size: 1819 bytes --]



On Aug 27, 2022, at 7:11 AM, Ihor Radchenko <yantar92@gmail.com<mailto:yantar92@gmail.com>> wrote:

---
lisp/ob-python.el | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 932aca08e..2ad907bd8 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -197,8 +197,7 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
  (setq py-buffer (org-babel-python-with-earmuffs session)))
(let ((python-shell-buffer-name
       (org-babel-python-without-earmuffs py-buffer)))
-   (run-python cmd)
-   (sleep-for 0 10)))
+   (run-python cmd)))
       ((and (eq 'python-mode org-babel-python-mode)
     (fboundp 'py-shell)) ; python-mode.el
(require 'python-mode)
@@ -225,8 +224,9 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
(defun org-babel-python-initiate-session (&optional session _params)
  "Create a session named SESSION according to PARAMS."
  (unless (string= session "none")
-    (org-babel-python-session-buffer
-     (org-babel-python-initiate-session-by-key session))))
+    (let ((session (org-babel-python-session-buffer
+                    (org-babel-python-initiate-session-by-key session)))))
+    (org-babel-comint-wait-for-output session)))

(defvar org-babel-python-eoe-indicator "org_babel_python_eoe"
  "A string to indicate that evaluation has completed.")
--
2.35.1

I get the following in the Messages:
org-babel-comint-wait-for-output: Buffer python-chain does not exist or has no process

Note that python-chain is the name of my session passed to the python blocks as shown in the following line within my org file.

#+PROPERTY: header-args:python :session python-chain :exports results :results raw file :file-ext table

Thanks,

Mark


[-- Attachment #2: Type: text/html, Size: 29021 bytes --]

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2022-08-27 18:56                                   ` Barton, Mark
@ 2022-08-27 21:31                                     ` Mark Barton
  2022-08-28  0:38                                       ` Barton, Mark
  0 siblings, 1 reply; 28+ messages in thread
From: Mark Barton @ 2022-08-27 21:31 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514, Lars Ingebrigtsen, Augusto Stoffel, Ihor Radchenko

[-- Attachment #1: Type: text/plain, Size: 2386 bytes --]



> On Aug 27, 2022, at 11:59 AM, Barton, Mark <Mark.Barton@disney.com> wrote:
> 
>  
> 
>> On Aug 27, 2022, at 7:11 AM, Ihor Radchenko <yantar92@gmail.com> wrote:
>> 
>> ---
>> lisp/ob-python.el | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/lisp/ob-python.el b/lisp/ob-python.el
>> index 932aca08e..2ad907bd8 100644
>> --- a/lisp/ob-python.el
>> +++ b/lisp/ob-python.el
>> @@ -197,8 +197,7 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
>> 	  (setq py-buffer (org-babel-python-with-earmuffs session)))
>> 	(let ((python-shell-buffer-name
>> 	       (org-babel-python-without-earmuffs py-buffer)))
>> -	  (run-python cmd)
>> -	  (sleep-for 0 10)))
>> +	  (run-python cmd)))
>>        ((and (eq 'python-mode org-babel-python-mode)
>> 	     (fboundp 'py-shell)) ; python-mode.el
>> 	(require 'python-mode)
>> @@ -225,8 +224,9 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
>> (defun org-babel-python-initiate-session (&optional session _params)
>>   "Create a session named SESSION according to PARAMS."
>>   (unless (string= session "none")
>> -    (org-babel-python-session-buffer
>> -     (org-babel-python-initiate-session-by-key session))))
>> +    (let ((session (org-babel-python-session-buffer
>> +                    (org-babel-python-initiate-session-by-key session)))))
>> +    (org-babel-comint-wait-for-output session)))
>> 
>> (defvar org-babel-python-eoe-indicator "org_babel_python_eoe"
>>   "A string to indicate that evaluation has completed.")
>> -- 
>> 2.35.1
> 
> I get the following in the Messages:
> org-babel-comint-wait-for-output: Buffer python-chain does not exist or has no process
> 
> Note that python-chain is the name of my session passed to the python blocks as shown in the following line within my org file.
> 
> #+PROPERTY: header-args:python :session python-chain :exports results :results raw file :file-ext table
> 
> Thanks,
> 
> Mark
> 
I will work on getting more details this weekend. It looked like the buffer passed to org-babel-comint-wait-for-output was missing the "earmuffs". I tried adding the earmuffs with the org function for that but although I got passed that error, I messed up my python session and the following python blocks were not aware of the imports in the first block.

Mark

 

[-- Attachment #2: Type: text/html, Size: 29460 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2022-08-27 21:31                                     ` Mark Barton
@ 2022-08-28  0:38                                       ` Barton, Mark
  2022-08-28  1:30                                         ` Ihor Radchenko
  0 siblings, 1 reply; 28+ messages in thread
From: Barton, Mark @ 2022-08-28  0:38 UTC (permalink / raw)
  To: Ihor Radchenko
  Cc: 50514@debbugs.gnu.org, Mark Barton, Lars Ingebrigtsen,
	Augusto Stoffel

[-- Attachment #1: Type: text/plain, Size: 1416 bytes --]


I will work on getting more details this weekend. It looked like the buffer passed to org-babel-comint-wait-for-output was missing the "earmuffs". I tried adding the earmuffs with the org function for that but although I got passed that error, I messed up my python session and the following python blocks were not aware of the imports in the first block.

Mark



I tried something that was suggested last September 14th by Augusto Stoffel. I had not tried it because changing the sleep from 10 to 90 was my workaround.
One thing that might work is to block until the shell is ready with something like

    (run-python)
    (with-current-buffer *the-shell-buffer*
      (while (not python-shell--first-prompt-received)
        (accept-process-output (get-buffer-process (current-buffer)))))

The patch that is working for me now is:

modified   lisp/org/ob-python.el
@@ -198,7 +198,10 @@ org-babel-python-initiate-session-by-key
  (let ((python-shell-buffer-name
        (org-babel-python-without-earmuffs py-buffer)))
   (run-python cmd)
-  (sleep-for 0 10)))
+          (with-current-buffer py-buffer
+            (while (not python-shell--first-prompt-received)
+              (accept-process-output (get-buffer-process (current-buffer)))))
+          ))
        ((and (eq 'python-mode org-babel-python-mode)
      (fboundp 'py-shell)) ; python-mode.el
  (require 'python-mode)


[-- Attachment #2: Type: text/html, Size: 5009 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2022-08-28  0:38                                       ` Barton, Mark
@ 2022-08-28  1:30                                         ` Ihor Radchenko
  2022-08-28  1:56                                           ` Barton, Mark
  0 siblings, 1 reply; 28+ messages in thread
From: Ihor Radchenko @ 2022-08-28  1:30 UTC (permalink / raw)
  To: Barton, Mark
  Cc: 50514@debbugs.gnu.org, Mark Barton, Lars Ingebrigtsen,
	Augusto Stoffel

[-- Attachment #1: Type: text/plain, Size: 967 bytes --]

"Barton, Mark" <Mark.Barton@disney.com> writes:

> I tried something that was suggested last September 14th by Augusto Stoffel. I had not tried it because changing the sleep from 10 to 90 was my workaround.
> One thing that might work is to block until the shell is ready with something like
>
>     (run-python)
>     (with-current-buffer *the-shell-buffer*
>       (while (not python-shell--first-prompt-received)
>         (accept-process-output (get-buffer-process (current-buffer)))))

Thanks, but it is not a good solution. Org cannot rely on internal
variables inside python.el (python-shell--first-prompt-received is an
internal variable). Internal variables are a subject of change without
notice.

May you instead try the attached alternative patch?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v2-0001-ob-python-Fix-Emacs-bug-50514-when-Python-loads-s.patch --]
[-- Type: text/x-patch, Size: 1642 bytes --]

From 06373a64387330d5bbdcbb3417cea7c2638713df Mon Sep 17 00:00:00 2001
Message-Id: <06373a64387330d5bbdcbb3417cea7c2638713df.1661650102.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 27 Aug 2022 22:06:11 +0800
Subject: [PATCH v2] ob-python: Fix Emacs bug#50514 when Python loads slowly

* lisp/ob-python.el (org-babel-python-initiate-session-by-key): Do not
rely on 10ms delay to initialize Python.  Wait until python process is
initialized using `org-babel-comint-wait-for-output'.
---
 lisp/ob-python.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 932aca08e..e50a7c2e2 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -197,8 +197,7 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
 	  (setq py-buffer (org-babel-python-with-earmuffs session)))
 	(let ((python-shell-buffer-name
 	       (org-babel-python-without-earmuffs py-buffer)))
-	  (run-python cmd)
-	  (sleep-for 0 10)))
+	  (run-python cmd)))
        ((and (eq 'python-mode org-babel-python-mode)
 	     (fboundp 'py-shell)) ; python-mode.el
 	(require 'python-mode)
@@ -217,6 +216,8 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
 	  (py-shell nil nil t org-babel-python-command py-buffer nil nil t nil)))
        (t
 	(error "No function available for running an inferior Python")))
+      ;; Wait until Python initializes.
+      (org-babel-comint-wait-for-output py-buffer)
       (setq org-babel-python-buffers
 	    (cons (cons session py-buffer)
 		  (assq-delete-all session org-babel-python-buffers)))
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2022-08-28  1:30                                         ` Ihor Radchenko
@ 2022-08-28  1:56                                           ` Barton, Mark
  2022-08-28  2:55                                             ` Ihor Radchenko
  0 siblings, 1 reply; 28+ messages in thread
From: Barton, Mark @ 2022-08-28  1:56 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen, Augusto Stoffel

[-- Attachment #1: Type: text/plain, Size: 1958 bytes --]



On Aug 27, 2022, at 6:30 PM, Ihor Radchenko <yantar92@gmail.com<mailto:yantar92@gmail.com>> wrote:

* lisp/ob-python.el (org-babel-python-initiate-session-by-key): Do not
rely on 10ms delay to initialize Python.  Wait until python process is
initialized using `org-babel-comint-wait-for-output'.
---
lisp/ob-python.el | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 932aca08e..e50a7c2e2 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -197,8 +197,7 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
  (setq py-buffer (org-babel-python-with-earmuffs session)))
(let ((python-shell-buffer-name
       (org-babel-python-without-earmuffs py-buffer)))
-   (run-python cmd)
-   (sleep-for 0 10)))
+   (run-python cmd)))
       ((and (eq 'python-mode org-babel-python-mode)
     (fboundp 'py-shell)) ; python-mode.el
(require 'python-mode)
@@ -217,6 +216,8 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
  (py-shell nil nil t org-babel-python-command py-buffer nil nil t nil)))
       (t
(error "No function available for running an inferior Python")))
+      ;; Wait until Python initializes.
+      (org-babel-comint-wait-for-output py-buffer)
      (setq org-babel-python-buffers
    (cons (cons session py-buffer)
  (assq-delete-all session org-babel-python-buffers)))
--
2.35.1

That works for me. I'm using a series of python blocks to create org tables to be inserted in specific places in the document. So each block is named for that reason.

Do we need to worry about the note about not appropriate for large blocks of code or does that not apply in this case with the way you implemented it.
(org-babel-comint-wait-for-output BUFFER)

Wait until output arrives from BUFFER.
Note: this is only safe when waiting for the result of a single
statement (not large blocks of code).

Mark

[-- Attachment #2: Type: text/html, Size: 31975 bytes --]

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* bug#50514: 28.0.50; org inline call to python src block req C-g to break
  2022-08-28  1:56                                           ` Barton, Mark
@ 2022-08-28  2:55                                             ` Ihor Radchenko
  0 siblings, 0 replies; 28+ messages in thread
From: Ihor Radchenko @ 2022-08-28  2:55 UTC (permalink / raw)
  To: Barton, Mark; +Cc: 50514@debbugs.gnu.org, Lars Ingebrigtsen, Augusto Stoffel

"Barton, Mark" <Mark.Barton@disney.com> writes:

> Do we need to worry about the note about not appropriate for large blocks of code or does that not apply in this case with the way you implemented it.
> (org-babel-comint-wait-for-output BUFFER)
>
> Wait until output arrives from BUFFER.
> Note: this is only safe when waiting for the result of a single
> statement (not large blocks of code).

It should not be a problem. org-babel-python-initiate-session-by-key is
creating a new python session---no actual code blocks are passed to
python; just the python command is executed.

Fixed on main via 06373a643.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=06373a64387330d5bbdcbb3417cea7c2638713df

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2022-08-28  2:55 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-10 23:06 bug#50514: 28.0.50; org inline call to python src block req C-g to break Barton, Mark
2021-09-11 13:04 ` Lars Ingebrigtsen
2021-09-11 13:26 ` Augusto Stoffel
2021-09-12  6:22   ` Barton, Mark
2021-09-12  6:51     ` Augusto Stoffel
2021-09-12  8:27       ` Barton, Mark
2021-09-12  9:15         ` Augusto Stoffel
2021-09-12 17:00           ` Barton, Mark
2021-09-12 20:04             ` Barton, Mark
2021-09-14  6:42               ` Augusto Stoffel
2021-09-14 17:54                 ` Barton, Mark
2021-09-14 18:29                   ` Augusto Stoffel
2021-09-14 19:25                     ` Barton, Mark
2021-09-14 19:31                       ` Augusto Stoffel
2021-09-14 22:20                         ` Barton, Mark
2021-09-15  6:28                           ` Augusto Stoffel
2021-09-14 19:36                       ` Augusto Stoffel
2021-09-15  8:02                         ` Lars Ingebrigtsen
2022-08-25 15:12                           ` Lars Ingebrigtsen
2022-08-26 13:30                             ` Ihor Radchenko
2022-08-27 13:16                               ` Lars Ingebrigtsen
2022-08-27 14:11                                 ` Ihor Radchenko
2022-08-27 18:56                                   ` Barton, Mark
2022-08-27 21:31                                     ` Mark Barton
2022-08-28  0:38                                       ` Barton, Mark
2022-08-28  1:30                                         ` Ihor Radchenko
2022-08-28  1:56                                           ` Barton, Mark
2022-08-28  2:55                                             ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.