GNU bug report logs - #17370
python-shell-internal-send-string can hang if you change your python prompt

Previous Next

Package: emacs;

Reported by: Andy Moreton <andrewjmoreton <at> gmail.com>

Date: Tue, 29 Apr 2014 12:13:01 UTC

Severity: normal

Found in versions 24.3, 24.3.90

Done: fgallina <at> gnu.org (Fabián Ezequiel Gallina)

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17370 in the body.
You can then email your comments to 17370 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#17370; Package emacs. (Tue, 29 Apr 2014 12:13:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andy Moreton <andrewjmoreton <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 29 Apr 2014 12:13:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andy Moreton <andrewjmoreton <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.90; user cannot disable inferior python run from python-mode
 when file is visited
Date: Tue, 29 Apr 2014 13:11:25 +0100
Load a file containing python code, in a file with extension ".py". This
will use python-mode as the major mode, which immediately runs an
inferior python executable.

I did not ask for a python interpreter, and do not want one running - I
just want to visit a file containing python code. There is not any
obvious way of disabling this behaviour.

Emacs should not run an arbitrary executable without explicit user
configuration to enable it.



In GNU Emacs 24.3.90.7 (i686-pc-mingw32)
 of 2014-04-29 on AJM-DESKTOP
Repository revision: 117027 
monnier <at> iro.umontreal.ca-20140429041427-c1v4orr7y23btoh2
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/emacs-emacs-24
 --with-pkg-config-prog=/c/emacs/mingw-devel/pkg-config-0.26-1/bin/pkg-config.exe
 --enable-checking PKG_CONFIG_PATH=/c/emacs/mingw-devel/lib/pkgconfig
 'CPPFLAGS= -I/c/emacs/mingw-devel/include
 -I/c/emacs/mingw-devel/src/xpm/3.5.1/libXpm-3.5.1-src/lib' 'CFLAGS= -O0
 -g3' 'LDFLAGS= -L/c/emacs/mingw-devel/lib''





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17370; Package emacs. (Tue, 29 Apr 2014 13:41:02 GMT) Full text and rfc822 format available.

Message #8 received at 17370 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Andy Moreton <andrewjmoreton <at> gmail.com>
Cc: 17370 <at> debbugs.gnu.org
Subject: Re: bug#17370: 24.3.90;
 user cannot disable inferior python run from python-mode when file is
 visited
Date: Tue, 29 Apr 2014 09:40:05 -0400
Andy Moreton wrote:

> Load a file containing python code, in a file with extension ".py". This
> will use python-mode as the major mode, which immediately runs an
> inferior python executable.

I cannot reproduce this. Does it happen with emacs -Q?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17370; Package emacs. (Tue, 29 Apr 2014 14:13:02 GMT) Full text and rfc822 format available.

Message #11 received at 17370 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Andy Moreton <andrewjmoreton <at> gmail.com>
Cc: 17370 <at> debbugs.gnu.org
Subject: Re: bug#17370: 24.3.90;
 user cannot disable inferior python run from python-mode when file is
 visited
Date: Tue, 29 Apr 2014 10:12:48 -0400
> Load a file containing python code, in a file with extension ".py". This
> will use python-mode as the major mode, which immediately runs an
> inferior python executable.

I do not see that.  Can you provide a recipe for that?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17370; Package emacs. (Tue, 29 Apr 2014 14:29:01 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#17370: 24.3.90; user cannot disable inferior python run from
 python-mode when file is visited
Date: Tue, 29 Apr 2014 16:28:13 +0200
On 29.04.2014 14:11, Andy Moreton wrote:
> Load a file containing python code, in a file with extension ".py". This
> will use python-mode as the major mode, which immediately runs an
> inferior python executable.
>
> I did not ask for a python interpreter, and do not want one running - I
> just want to visit a file containing python code. There is not any
> obvious way of disabling this behaviour.
>
> Emacs should not run an arbitrary executable without explicit user
> configuration to enable it.
>
>

Reads you installed one of the IDE's around.
Should not happen when starting from emacs -Q





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17370; Package emacs. (Tue, 29 Apr 2014 15:59:02 GMT) Full text and rfc822 format available.

Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andy Moreton <andrewjmoreton <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#17370: 24.3.90;
 user cannot disable inferior python run from python-mode when file is
 visited
Date: Tue, 29 Apr 2014 16:06:22 +0100
On Tue 29 Apr 2014, Stefan Monnier wrote:

>> Load a file containing python code, in a file with extension ".py". This
>> will use python-mode as the major mode, which immediately runs an
>> inferior python executable.
>
> I do not see that.  Can you provide a recipe for that?
>
>
>         Stefan

It seems that the problem is caused by this in my .emacs:
    (global-ede-mode 1)
    (ede-enable-generic-projects)

Some combination of the two causes emacs to load an inferior python and
then run at 100% cpu for approx 30-40 seconds.

As the EDE stuff was only there for experimenting with EDE and Semantic,
so I'll remove it (fixing the Semantic/EDE docs to be useful is another
story).

    AndyM





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17370; Package emacs. (Fri, 02 May 2014 20:11:02 GMT) Full text and rfc822 format available.

Message #20 received at 17370 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Andy Moreton <andrewjmoreton <at> gmail.com>
Cc: 17370 <at> debbugs.gnu.org, Fabian Ezequiel Gallina <fabian <at> anue.biz>
Subject: Re: bug#17370: 24.3.90;
 user cannot disable inferior python run from python-mode when file is
 visited
Date: Fri, 02 May 2014 16:10:34 -0400
The issue seems to be that semantic-python-get-system-include-path runs
some code to get the Python system include path (IMO this is a
reasonable thing for it to do and I don't see the need to have an option
controlling this).

This calls:

(python-shell-internal-send-string "import sys;print ('\\n'.join(sys.path))")

It is this that hangs (in python-shell-send-string-no-output AFAICS).
It also hangs in Emacs 24.3.

emacs -Q -l python

and evaluate the above.




bug Marked as found in versions 24.3. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 02 May 2014 20:12:01 GMT) Full text and rfc822 format available.

Changed bug title to 'python-shell-internal-send-string hangs' from '24.3.90; user cannot disable inferior python run from python-mode when file is visited' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 02 May 2014 20:12:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17370; Package emacs. (Fri, 02 May 2014 20:57:02 GMT) Full text and rfc822 format available.

Message #27 received at 17370 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Andy Moreton <andrewjmoreton <at> gmail.com>
Cc: 17370 <at> debbugs.gnu.org, Fabian Ezequiel Gallina <fabian <at> anue.biz>
Subject: Re: bug#17370: 24.3.90;
 user cannot disable inferior python run from python-mode when file is
 visited
Date: Fri, 02 May 2014 16:56:16 -0400
Glenn Morris wrote:

> (python-shell-internal-send-string "import sys;print ('\\n'.join(sys.path))")
>
> It is this that hangs (in python-shell-send-string-no-output AFAICS).
> It also hangs in Emacs 24.3.
>
> emacs -Q -l python

It seems that for me the hang is because I have customized my python
prompt (sys.ps1 = 'py> ' in ~/.pythonrc.py).

I have to set python-shell-prompt-regexp to match to avoid a hang as
python.el thinks it needs to keep waiting for process output.

Can python.el be made more robust in this regard?

Otherwise there needs to be a big fat warning attached to
python-shell-prompt-regexp.




Changed bug title to 'python-shell-internal-send-string can hang if you change your python prompt' from 'python-shell-internal-send-string hangs' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 03 May 2014 01:27:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17370; Package emacs. (Sun, 15 Jun 2014 17:26:02 GMT) Full text and rfc822 format available.

Message #32 received at 17370 <at> debbugs.gnu.org (full text, mbox):

From: fgallina <at> gnu.org (Fabián Ezequiel Gallina)
To: Glenn Morris <rgm <at> gnu.org>, 17370 <at> debbugs.gnu.org
Subject: Re: bug#17370: 24.3.90;
 user cannot disable inferior python run from python-mode when file is
 visited
Date: Sun, 15 Jun 2014 14:12:32 -0300
Glenn Morris <rgm <at> gnu.org> writes:

> Glenn Morris wrote:
>
>> (python-shell-internal-send-string "import sys;print ('\\n'.join(sys.path))")
>>
>> It is this that hangs (in python-shell-send-string-no-output AFAICS).
>> It also hangs in Emacs 24.3.
>>
>> emacs -Q -l python
>
> It seems that for me the hang is because I have customized my python
> prompt (sys.ps1 = 'py> ' in ~/.pythonrc.py).
>
> I have to set python-shell-prompt-regexp to match to avoid a hang as
> python.el thinks it needs to keep waiting for process output.
>
> Can python.el be made more robust in this regard?
>
> Otherwise there needs to be a big fat warning attached to
> python-shell-prompt-regexp.
>
>
>
>

We definitely can do better.

One way would be to set the prompt regexp dynamically using the values
of sys.ps1 and sys.ps2. But then we also need to be careful as those
values for ipython are a lie:

    $ ipython
    Python 2.7.6 (default, Mar 22 2014, 22:59:56)
    Type "copyright", "credits" or "license" for more information.

    IPython 1.2.1 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.

    In [1]: import sys

    In [2]: sys.ps1
    Out[2]: 'In : '

Perhaps the best way to go is a mixture of the current way and
dinamically expanding `python-shell-prompt-regexp` with sys.ps1 and
sys.ps2. I'll give it a try in the next few weeks and follow up once I
see how it goes.


    Fabián




Reply sent to fgallina <at> gnu.org (Fabián Ezequiel Gallina):
You have taken responsibility. (Sat, 19 Jul 2014 13:29:02 GMT) Full text and rfc822 format available.

Notification sent to Andy Moreton <andrewjmoreton <at> gmail.com>:
bug acknowledged by developer. (Sat, 19 Jul 2014 13:29:03 GMT) Full text and rfc822 format available.

Message #37 received at 17370-done <at> debbugs.gnu.org (full text, mbox):

From: fgallina <at> gnu.org (Fabián Ezequiel Gallina)
To: 17370-done <at> debbugs.gnu.org
Subject: python-shell-internal-send-string can hang if you change your python
 prompt
Date: Sat, 19 Jul 2014 10:28:31 -0300
Fixed in the emacs-24 branch at revno 117387.



Cheers,
Fabián




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 17 Aug 2014 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 262 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.