Subject: bug#50669: 28.0.50; python-shell-send-string leads to "nesting exceeds `max-lisp-eval-depth`" error

From: Michael-David Fiszer <[email-masked]>
Date: Wed, 22 Sep 2021 00:17:27 +0300

Hi!

- I'm pretty sure I'm on the master branch. I don't clone from git, but I
compared my version of python.el with this
https://github.com/emacs-mirror/emacs/commit/6cfc312d7196d7c7c70e7030b344891ecea8c4f1#diff-f808b0589744f83f41d9f581e8b07001145598d2a2aa07fd40c1d20ee35df762
and it looks up to date.

- Regarding the recursive calls, I tried to look into it, and what I found
was very confusing.
  - The tests I sent on number of characters, I believe establish that the
issue only arises when the string is long enough for
python-shell-send-string to save to a file and call python-shell-send file.
  - The backtrace - I sent to you. I suppose it's hard to decipher.
  - I then tried setting a breakpoint in 'python-shell-send-string. If I
step through commands there, I see myself looping through this function
again and again (creating more and more files, which is eventually what
leads to the error). Buf *if* I step into 'python-shell-send-file when
going through the difference expressions of 'python-shell-send-string, I
get into the function (which indeed calls 'comint-send-string, not
'python-shell-send-string... and at this point, instead of returning to the
*beginning* of python-shell-send string, I end up exiting
python-shell-send-string and everything works.
      - In other words, the problem does not arise in edebug mode *if* I
step into python-shell-send-file when python-shell-send-string calls it.

This is very weird, sounds like perhaps some async issue... Very odd.

On Sun, Sep 19, 2021 at 7:13 PM Augusto Stoffel <[email-masked]> wrote:

> Hi David,
>
> So, I think the main thing is to figure out which functions are calling
> themselves recursively.  'python-shell-send-file' doesn't call
> 'python-shell-send-string' anymore, so that can't be it (are you sure
> you are using today's master branch?).
>
> Another crazy attempt would be this:
>
>      (let ((process-connection-type nil)
>            (python-shell-completion-native-enable nil))
>        (run-python))
>
> Nevermind the initial warnings, does it work for you afterwards?
>