From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Subject: Re: python sessions Date: Sat, 30 Mar 2013 08:19:37 +0100 Message-ID: <51569209.3050801@easy-emacs.de> References: <514AB9FC.3050601@easy-emacs.de> <87d2ut2o5m.fsf@bzg.ath.cx> <514AC116.7030408@easy-emacs.de> <877gkxrbgn.fsf@gmail.com> <514EAF96.3030402@easy-emacs.de> <17915.1364144298@alphaville> <18546.1364150504@alphaville> <5150B790.2040603@easy-emacs.de> <87boa7upoc.fsf@gmail.com> <51514059.1020902@easy-emacs.de> <87li9a72vn.fsf@gmail.com> <51528F56.7090605@easy-emacs.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:58715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULq3T-0006ez-6U for emacs-orgmode@gnu.org; Sat, 30 Mar 2013 03:18:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULq3S-0003oW-0I for emacs-orgmode@gnu.org; Sat, 30 Mar 2013 03:18:23 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:51431) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULq3R-0003oD-NR for emacs-orgmode@gnu.org; Sat, 30 Mar 2013 03:18:21 -0400 In-Reply-To: <51528F56.7090605@easy-emacs.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Gary Oberbrunner Am 27.03.2013 07:19, schrieb Andreas Röhler: > Am 26.03.2013 22:41, schrieb Gary Oberbrunner: >> I did some further testing. With my patch, my real org-mode python file is >> now actually working. There were a few gotchas I didn't understand about >> session mode and python and matplotlib: >> >> 1. In session mode, you are essentially running an interactive python. >> (This is made explicit by my patch, which passes -i). >> 2. In interactive mode, blank lines are special: they indicate the end of >> an indented block. So you have to write your org-mode python a little >> differently when using session mode. >> 3. matplotlib uses an "interactive" backend when started from an >> interactive python (sensibl y). So you have to set the backend explicitly >> when using session mode, or it hangs forever with no indication what's >> wrong. >> 4. ob-python does not handle python errors at all in session mode: it >> ignores them silently. This makes it really hard to debug the python code. >> >> I'd like to document #s 1-3; where should that go? >> I'd like to work on a patch for #4; it seems like the only thing is to >> search in the session buffer for likely error strings. Is there any better >> method anyone can think of? >> > > AFAIU the error string is missing, because it's sent the wrong path-to-interpreter, > i.e. using shell-command. > Shell returns 0 or 1, not the Python errors. > > Also the interactive spec is related. Usually Python shell as started from py-shell or run-python include this already. > When send from a python-mode, also the empty lines you mentioned and related stuff is treated. > > Andreas > > > That turned out not being the case. I'm quoting: > This is incorrect. In session mode, there is one long-running python > interpreter session. Emacs passes it code snippets, and it spits out > stdout and stderr (all mixed up: output from your program, the lines > themselves which get echoed, prompts, and error messages if any). There is > never any "return" value since the python interpreter doesn't exit. The > only way to handle errors in interactive mode AFAICS is to use approximate > regexes to look for errors, un-handled exceptions and so on. > Cheers