GNU bug report logs -
#17370
python-shell-internal-send-string can hang if you change your python prompt
Previous Next
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.
Full log
View this message in rfc822 format
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
This bug report was last modified 10 years and 305 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.