From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mark Barton Newsgroups: gmane.emacs.bugs,gmane.emacs.devel Subject: bug#49822: master e32c7d2: Change Python eval to send directly instead of using temporary files Date: Sun, 5 Sep 2021 10:33:45 -0700 Message-ID: References: <20210903122828.16890.65271@vcs0.savannah.gnu.org> <20210903122829.EAAC220B71@vcs0.savannah.gnu.org> <87r1e4eklw.fsf@gmail.com> <44E9472D-65D9-48DA-AF20-C0A82818C5CA@disney.com> <87ilzfcuj2.fsf@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_784EBF37-5BE8-49A7-9A83-7B8D9F4CCBA2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39522"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "49822@debbugs.gnu.org" <49822@debbugs.gnu.org>, Stefan Monnier , "emacs-devel@gnu.org" To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 05 19:34:18 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mMw25-000A3P-DU for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Sep 2021 19:34:17 +0200 Original-Received: from localhost ([::1]:47472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMw23-0008Uu-WC for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Sep 2021 13:34:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMw1q-0008TF-8i for bug-gnu-emacs@gnu.org; Sun, 05 Sep 2021 13:34:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMw1q-0008HB-0F for bug-gnu-emacs@gnu.org; Sun, 05 Sep 2021 13:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mMw1p-00013H-RD for bug-gnu-emacs@gnu.org; Sun, 05 Sep 2021 13:34:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark Barton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Sep 2021 17:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49822 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 49822-submit@debbugs.gnu.org id=B49822.16308632354019 (code B ref 49822); Sun, 05 Sep 2021 17:34:01 +0000 Original-Received: (at 49822) by debbugs.gnu.org; 5 Sep 2021 17:33:55 +0000 Original-Received: from localhost ([127.0.0.1]:50949 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMw1i-00012j-BJ for submit@debbugs.gnu.org; Sun, 05 Sep 2021 13:33:54 -0400 Original-Received: from mail-pg1-f182.google.com ([209.85.215.182]:38545) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMw1f-00012W-S9 for 49822@debbugs.gnu.org; Sun, 05 Sep 2021 13:33:52 -0400 Original-Received: by mail-pg1-f182.google.com with SMTP id w8so4336995pgf.5 for <49822@debbugs.gnu.org>; Sun, 05 Sep 2021 10:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=WUwORsY42bnuBOQ3pAcvAAyWvmytm22Y2rcLVGNMvuo=; b=jFDBcbkBFou1T5snTA4/Mlelxa9TfYwiFZjpdfD5vS9kCRK18CTjNdPUMt4nJZIEgO 877XdHZcDcpEujCAKzta4EwIQAySfABhn8ro9jYf6+N+xNi9uJ21gz0BitX6m8Dk7xaL n2xYpfA/9Q68P4C6RgBhQ+9OI6J0bCh0QjYpbXuAmExfDwo3+nfuniAquT+5o16pyTpb tFLY4+MLjC4GmlNnQOgVRSWsVpr5BYA3Pq5CH2PU64QvpirOlF5xkRC7JkkupuWFyLcX B+BdzFaVuE+bnUiwFYOwLythybQ6xv5OZOxQtwIuHsnbZVS8UFKYxavj17kRWW0iPy/S 4YWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=WUwORsY42bnuBOQ3pAcvAAyWvmytm22Y2rcLVGNMvuo=; b=Hqi3o65ooM0VkGUeABG+FivfumyahfeGi3AQ0BQ2sYVI8cNgT8p0IOyK/TqgESzHxa ZVqzwQsMisN5NF+chQxuNvuFTVYDjohCXnrbqwGdu2WxvgWnh/cuktcYFaFh6qEf/2qi HoIyUfWSBqK9B8AvkRI1Jq5AOymkZesd0rKuXuGRd3Fa70B5bUYsSmKoJpk+m07mdFyM zNAiYX9zZ2wyVvsCab0BACNVeCy4/zIrH6VGskq8bv59DknZXnc0TIk+3AmxIu0+bLJ3 +mU/uoG3DixqTw0l0AusZ3vIvuIcgC/7jfgB9qytlH2RFqvwPEI++xmTT+XgQ6kfJoAx a+9w== X-Gm-Message-State: AOAM5329KhGpZW8gItnIOud3+QBMJ20SYkV9rN4uqxVKT8lKQCzhIR5e aRmQZkNY80XO7KBIuxZ+DPw= X-Google-Smtp-Source: ABdhPJxS3kqH/MULTmpMb721rdsUhQ47S/HLbILeewOCwHk/fKG8oQ+FMxd7zVX04iT+BFzIDfOgtg== X-Received: by 2002:aa7:9787:0:b0:409:7f3e:82b5 with SMTP id o7-20020aa79787000000b004097f3e82b5mr8142124pfp.51.1630863225884; Sun, 05 Sep 2021 10:33:45 -0700 (PDT) Original-Received: from smtpclient.apple (2603-8001-7a00-01a0-18bb-b3d0-e23d-95e9.res6.spectrum.com. [2603:8001:7a00:1a0:18bb:b3d0:e23d:95e9]) by smtp.gmail.com with ESMTPSA id gm5sm5173607pjb.32.2021.09.05.10.33.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Sep 2021 10:33:45 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.13) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:213523 gmane.emacs.devel:274022 Archived-At: --Apple-Mail=_784EBF37-5BE8-49A7-9A83-7B8D9F4CCBA2 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 5, 2021, at 10:18 AM, Mark Barton wrote: >=20 >=20 >=20 >> On Sep 5, 2021, at 1:10 AM, Augusto Stoffel > wrote: >>=20 >> On Sun, 5 Sep 2021 at 06:13, "Barton, Mark" > wrote: >>=20 >>> Today I was trying to export my monthly org document that uses org = babel python blocks to >>> produce tables. I can get it to export fine if I revert python.el to = the version before e32c7d2a8d >>> - Change Python eval to send directly instead of using temporary = files. >>>=20 >>> Below I show the python session buffer, first where it is working = and then where it is broken for >>> me. I=E2=80=99m running Emacs on macOS 11.5.1 and compile from the = master branch. >>>=20 >>> In the =E2=80=9CBroken session buffer=E2=80=9D below, I recognize = the code from that commit, but I really don=E2=80=99t >>> understand the problem. Any ideas on what other information I can = gather that would be >>> useful? >>=20 >> Two more things you could try: >>=20 >> 1) set `python-shell-completion-native-enable' to nil >> 2) pull the current master, after commit 1fdd898704 >>=20 >> I'd be curious to see the effect of 1) before doing 2), if you have = the >> time for this quick test. >=20 >=20 > I created a test org and csv file to test. Before I added the inline = call to the test file, changing the = python-shell-completion-native-enable to nil did get the my def pd2org = to work. Otherwise it would work on the second export if I did not kill = the python-chain session. The inline call to file_date returns an error = =E2=80=9CInline error: multiline result cannot be used=E2=80=9D >=20 > The attached pdf shows the successful export when I use the previous = python.el. >=20 > I just compiled from master at commit c5b654b3f1 >=20 > Recent commits > c5b654b3f1 master origin/master Autoload cl-struct-slot-info > 7c7a47b86e ; * etc/NEWS: Fix a recent change. > 3d0276e98b Improve the documentation around the read-key/minibuffer = prompting > 73a90cda4a Clarify completion-list-mode NEWS entry > 8f2e8add98 ; * doc/emacs/maintaining.texi (Looking Up Identifiers): = Fix last change. > 0972cbe42f * lisp/progmodes/xref.el: Fix defcustoms (bug#50067) > 2ed2999ce5 Improve documentation of new Xref options > 1fdd898704 Fixes for 'python-shell-send-string' and = 'python-shell-send-file' > ba84ec8bd9 Fix error handling in 'ispell-init-process' > e6f936eb4d Cleanup tramp-tests.el >=20 > Setting the python-shell-completion-native-enable to nil cleans up the = session buffer python-chain >=20 > Python 3.9.6 (default, Jun 29 2021, 05:25:02)=20 > [Clang 12.0.5 (clang-1205.0.22.9)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>>=20 > org_babel_python_eoe > >>>=20 > 2021-08-24org_babel_python_eoe > >>>=20 > org_babel_python_eoe > >>>=20 > org_babel_python_eoe > >>>=20 > 2021-09-05org_babel_python_eoe > >>>=20 >=20 > But I now get the error that prevents the pdf export: =E2=80=9CInline = error: multiline result cannot be used" > > > Here is a simpler one to attempt to reproduce. If I comment out the = #+PROPERTY line to not use a session then it works. With the #+PROPERTY = line, I get the =E2=80=9CInline error: multiline result cannot be = used=E2=80=9D. #+TITLE: Test Org Babel Export with Python Blocks #+AUTHOR: Mark Barton #+DATE: 2021-09-05 #+OPTIONS: toc:nil H:4 num:nil ^:nil #+EXCLUDE_TAGS: ignore #+LATEX_CLASS: article #+LaTeX_HEADER: \usepackage[letterpaper,margin=3D0.5in, = bottom=3D1in]{geometry} #+latex_header: \usepackage{float} #+LaTeX_HEADER: \usepackage{enumitem}\setlist[itemize]{nosep} #+LaTeX_HEADER: \usepackage{needspace} #+LaTeX_HEADER: \usepackage{booktabs} #+LaTeX_HEADER: \usepackage{xcolor} #+LaTeX_HEADER: \let\OldRule\rule #+LaTeX_HEADER: \renewcommand{\rule}[2]{\OldRule{\linewidth}{#2}} #+LaTeX_HEADER: \setlength{\parindent}{0pt} #+LaTeX_HEADER: \setlength{\parskip}{12pt} #+PROPERTY: header-args:python :session python-chain :exports results = :results raw replace =20 *** Initialize python = :ignore: #+NAME: file_date #+begin_src python :var file=3D"Roster_Report.csv" :exports none import os import time print(time.strftime("%Y-%m-%d",time.localtime(os.path.getmtime(file))), = end=3D"") #+end_src *** Summary Test inline call_file_date[:results output :results = raw](file=3D"./ts_org_babel_python.csv") --Apple-Mail=_784EBF37-5BE8-49A7-9A83-7B8D9F4CCBA2 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8


On Sep 5, 2021, at 10:18 AM, = Mark Barton <mbarton98@gmail.com> wrote:



On Sep 5, 2021, at 1:10 AM, Augusto Stoffel <arstoffel@gmail.com>= wrote:

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

Today I was trying to = export my monthly org document that uses org babel python blocks to
produce tables. I can get it to export fine if I revert = python.el to the version before e32c7d2a8d
- Change Python = eval to send directly instead of using temporary files.

Below I show the python session buffer, first where it is = working and then where it is broken for
me. I=E2=80=99m = running Emacs on macOS 11.5.1 and compile from the master branch.

In the =E2=80=9CBroken session buffer=E2=80=9D = below, I recognize the code from that commit, but I really don=E2=80=99tunderstand the problem. Any ideas on what other information = I can gather that would be
useful?

Two more things you could try:

1) set `python-shell-completion-native-enable' = to nil
2) pull the current master, after commit = 1fdd898704

I'd be curious to see the effect = of 1) before doing 2), if you have the
time for this quick = test.

I created a test org and csv file to = test. Before I added the inline call to the test file, changing the = python-shell-completion-native-enable to nil did get the my def pd2org = to work. Otherwise it would work on the second export if I did not kill = the python-chain session. The inline call to file_date returns an error = =E2=80=9CInline error: multiline result cannot be used=E2=80=9D

The attached pdf shows = the successful export when I use the previous python.el.

I just compiled from = master at commit c5b654b3f1

Recent commits
c5b654b3f1= master origin/master Autoload cl-struct-slot-info
7c7a47b86e ; * etc/NEWS: Fix a recent change.
3d0276e98b Improve the documentation around the = read-key/minibuffer prompting
73a90cda4a Clarify = completion-list-mode NEWS entry
8f2e8add98 ; * = doc/emacs/maintaining.texi (Looking Up Identifiers): Fix last = change.
0972cbe42f * lisp/progmodes/xref.el: Fix = defcustoms (bug#50067)
2ed2999ce5 Improve = documentation of new Xref options
1fdd898704 Fixes = for 'python-shell-send-string' and 'python-shell-send-file'
ba84ec8bd9 Fix error handling in = 'ispell-init-process'
e6f936eb4d Cleanup = tramp-tests.el

Setting the python-shell-completion-native-enable to nil = cleans up the session buffer python-chain

Python 3.9.6 (default, = Jun 29 2021, 05:25:02) 
[Clang 12.0.5 = (clang-1205.0.22.9)] on darwin
Type "help", = "copyright", "credits" or "license" for more information.
>>> 
org_babel_python_eoe
>>> 
2021-08-24org_babel_python_eoe
>>> 
org_babel_python_eoe
>>> 
org_babel_python_eoe
>>> 
2021-09-05org_babel_python_eoe
>>> 

But I now get the error that prevents = the pdf export: =E2=80=9CInline error: multiline result cannot be = used"
<ts_org_babel_python.cs= v>
<ts_org_babel_python.org>
<ts_org_babel_python.pd= f>

Here is a simpler one to attempt to reproduce. If I comment = out the #+PROPERTY line to not use a session then it works. With = the #+PROPERTY line, I get the =E2=80=9CInline error: multiline = result cannot be used=E2=80=9D.


#+TITLE: Test Org Babel Export with Python Blocks
#+AUTHOR: Mark Barton
#+DATE: = 2021-09-05
#+OPTIONS: toc:nil H:4 num:nil = ^:nil
#+EXCLUDE_TAGS: ignore
#+LATEX_CLASS: article
#+LaTeX_HEADER: = \usepackage[letterpaper,margin=3D0.5in, bottom=3D1in]{geometry}
#+latex_header: \usepackage{float}
#+LaTeX_HEADER: = \usepackage{enumitem}\setlist[itemize]{nosep}
#+LaTeX_HEADER: \usepackage{needspace}
#+LaTeX_HEADER: \usepackage{booktabs}
#+LaTeX_HEADER: \usepackage{xcolor}
#+LaTeX_HEADER: \let\OldRule\rule
#+LaTeX_HEADER: = \renewcommand{\rule}[2]{\OldRule{\linewidth}{#2}}
#+LaTeX_HEADER: \setlength{\parindent}{0pt}
#+LaTeX_HEADER: \setlength{\parskip}{12pt}
#+PROPERTY: header-args:python :session python-chain :exports = results :results raw replace

      
*** Initialize python           =                     =               =  :ignore:

#+NAME: file_date
#+begin_src python = :var file=3D"Roster_Report.csv" :exports none
import = os
import time
print(time.strftime("%Y-%m-%d",time.localtime(os.path.getmtime(= file))), end=3D"")
#+end_src

***= Summary

Test = inline call_file_date[:results output :results = raw](file=3D"./ts_org_babel_python.csv")

= --Apple-Mail=_784EBF37-5BE8-49A7-9A83-7B8D9F4CCBA2--