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

Previous Next

Package: emacs;

Reported by: Michael-David Fiszer <sguibor <at> gmail.com>

Date: Sun, 19 Sep 2021 02:42:01 UTC

Severity: normal

Tags: moreinfo

Found in version 28.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 50669 in the body.
You can then email your comments to 50669 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#50669; Package emacs. (Sun, 19 Sep 2021 02:42:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael-David Fiszer <sguibor <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 19 Sep 2021 02:42:02 GMT) Full text and rfc822 format available.

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

From: Michael-David Fiszer <sguibor <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; python-shell-send-string leads to "nesting exceeds
 `max-lisp-eval-depth`" error
Date: Sun, 19 Sep 2021 03:32:30 +0300
[Message part 1 (text/plain, inline)]
Hi,

I'm not an expert in how python.el internals work, but I started getting
this error every time I would send a statement to the shell. In addition I
would get these weird printouts of blocks of the form

```
  def __PYDOC_get_help(obj):
    try:
        import inspect
        try:
            str_type = basestring
            argspec_function = inspect.getargspec
        except NameError:
            str_type = str
```

while just moving the point in my .py file.

My current workaround was to simply override python-shell-send-string from
28.0.50 with the one I had with my emacs 27 version, which was:

```
(defun python-shell-send-string (string &optional process msg)
  "Send STRING to inferior Python PROCESS.
When optional argument MSG is non-nil, forces display of a
user-friendly message if there's no process running; defaults to
t when called interactively."
  (interactive
   (list (read-string "Python command: ") nil t))
  (let ((process (or process (python-shell-get-process-or-error msg))))
    (if (string-match ".\n+." string)   ;Multiline.
        (let* ((temp-file-name (python-shell--save-temp-file string))
               (file-name (or (buffer-file-name) temp-file-name)))
          (python-shell-send-file file-name process temp-file-name t))
      (when (or (not (string-match "\n\\'" string))
                (string-match "\n[ \t].*\n?\\'" string))
        (comint-send-string process "\n")))))
```

And this seems to solve the problem...


In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.6.0, NS appkit-2022.60
Version 11.6 (Build 20G165))
 of 2021-09-17 built on mdfz-macbookpro4.roam.corp.google.com
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.6

Configured using:
 'configure --disable-dependency-tracking --disable-silent-rules
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs-plus <at> 28/28.0.50/share/info/emacs
 --prefix=/usr/local/Cellar/emacs-plus <at> 28/28.0.50 --with-xml2 --with-gnutls
 --without-dbus --with-imagemagick --with-modules --with-rsvg --with-ns
 --disable-ns-self-contained'

Configured features:
ACL GLIB GMP GNUTLS IMAGEMAGICK JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY
KQUEUE NS
PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: mu4e-headers

Memory information:
((conses 16 1905022 1639005)
 (symbols 48 123242 97)
 (strings 32 433582 151543)
 (string-bytes 1 14825386)
 (vectors 16 192606)
 (vector-slots 8 3165377 831342)
 (floats 8 1100 6586)
 (intervals 56 34684 19693)
 (buffers 992 60))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50669; Package emacs. (Sun, 19 Sep 2021 09:11:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Michael-David Fiszer <sguibor <at> gmail.com>
Cc: 50669 <at> debbugs.gnu.org
Subject: Re: bug#50669: 28.0.50; python-shell-send-string leads to "nesting
 exceeds `max-lisp-eval-depth`" error
Date: Sun, 19 Sep 2021 11:10:00 +0200
On Sun, 19 Sep 2021 at 03:32, Michael-David Fiszer <sguibor <at> gmail.com> wrote:

> Hi,

Hi,

Can you try 'M-x toggle-debug-on-error', or maybe tracing some
functions, to discover what is being called repeatedly?

Also, what happens if you (setq python-eldoc-get-doc nil) in the .py
file's buffer?

Some more macos-related things that would be helpful to know:

* On a freshly started python-shell, is are the functions
  __PYTHON_EL_eval and __PYTHON_EL_eval_file defined?

* If you do M-x python-shell-send-string RET x="aaa...aaa" or something
  like that, can you evaluate Python statements that are, say, 900 and
  1100 characters long?


>
> I'm not an expert in how python.el internals work, but I started getting this error every time I would
> send a statement to the shell. In addition I would get these weird printouts of blocks of the form
>
> ```
>   def __PYDOC_get_help(obj):
>     try:
>         import inspect
>         try:
>             str_type = basestring
>             argspec_function = inspect.getargspec
>         except NameError:
>             str_type = str
> ```
>
> while just moving the point in my .py file.
>
> My current workaround was to simply override python-shell-send-string from 28.0.50 with the one
> I had with my emacs 27 version, which was:
>
> ```
> (defun python-shell-send-string (string &optional process msg)
>   "Send STRING to inferior Python PROCESS.
> When optional argument MSG is non-nil, forces display of a
> user-friendly message if there's no process running; defaults to
> t when called interactively."
>   (interactive
>    (list (read-string "Python command: ") nil t))
>   (let ((process (or process (python-shell-get-process-or-error msg))))
>     (if (string-match ".\n+." string)   ;Multiline.
>         (let* ((temp-file-name (python-shell--save-temp-file string))
>                (file-name (or (buffer-file-name) temp-file-name)))
>           (python-shell-send-file file-name process temp-file-name t))
>       (when (or (not (string-match "\n\\'" string))
>                 (string-match "\n[ \t].*\n?\\'" string))
>         (comint-send-string process "\n")))))
> ```
>
> And this seems to solve the problem...
>
> In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.6.0, NS appkit-2022.60 Version 11.6
> (Build 20G165))
>  of 2021-09-17 built on mdfz-macbookpro4.roam.corp.google.com
> Windowing system distributor 'Apple', version 10.3.2022
> System Description:  macOS 11.6
>
> Configured using:
>  'configure --disable-dependency-tracking --disable-silent-rules
>  --enable-locallisppath=/usr/local/share/emacs/site-lisp
>  --infodir=/usr/local/Cellar/emacs-plus <at> 28/28.0.50/share/info/emacs
>  --prefix=/usr/local/Cellar/emacs-plus <at> 28/28.0.50 --with-xml2 --with-gnutls
>  --without-dbus --with-imagemagick --with-modules --with-rsvg --with-ns
>  --disable-ns-self-contained'
>
> Configured features:
> ACL GLIB GMP GNUTLS IMAGEMAGICK JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE
> NS
> PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM ZLIB
>
> Important settings:
>   value of $LC_ALL: en_US.UTF-8
>   value of $LC_CTYPE: en_US.UTF-8
>   value of $LANG: en_US.UTF-8
>   locale-coding-system: utf-8-unix
>
> Major mode: mu4e-headers
>
> Memory information:
> ((conses 16 1905022 1639005)
>  (symbols 48 123242 97)
>  (strings 32 433582 151543)
>  (string-bytes 1 14825386)
>  (vectors 16 192606)
>  (vector-slots 8 3165377 831342)
>  (floats 8 1100 6586)
>  (intervals 56 34684 19693)
>  (buffers 992 60))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50669; Package emacs. (Sun, 19 Sep 2021 09:29:02 GMT) Full text and rfc822 format available.

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

From: Michael-David Fiszer <sguibor <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 50669 <at> debbugs.gnu.org
Subject: Re: bug#50669: 28.0.50; python-shell-send-string leads to "nesting
 exceeds `max-lisp-eval-depth`" error
Date: Sun, 19 Sep 2021 12:28:04 +0300
[Message part 1 (text/plain, inline)]
Hi!

Thanks for the response!

I'll fill in the details shortly. I wanted to add to the bug, that the
functions being called repeatedly were `python-shell-send-string` and
`python-shell-send-file`.

They call one another and create more and more temporary files before I get
the recursion error.

As a side note, python.el really rocks. Thanks so much for the amazing work.

On Sun, Sep 19, 2021 at 12:10 PM Augusto Stoffel <arstoffel <at> gmail.com>
wrote:

> On Sun, 19 Sep 2021 at 03:32, Michael-David Fiszer <sguibor <at> gmail.com>
> wrote:
>
> > Hi,
>
> Hi,
>
> Can you try 'M-x toggle-debug-on-error', or maybe tracing some
> functions, to discover what is being called repeatedly?
>
> Also, what happens if you (setq python-eldoc-get-doc nil) in the .py
> file's buffer?
>

I'll try this asap. I thought it was eldoc, but then tried turning off
'eldoc-mode' off and I still had the same problem with the infinite
recursion (and I think I still saw the weird PYDOC strings, but not sure).

But I will try this today.


>
> Some more macos-related things that would be helpful to know:
>
> * On a freshly started python-shell, is are the functions
>   __PYTHON_EL_eval and __PYTHON_EL_eval_file defined?
>

I just checked, and they both are.

<function __main__.__PYTHON_EL_eval(source, filename)>
<function __main__.__PYTHON_EL_eval_file(filename, tempname, delete)>

>
> * If you do M-x python-shell-send-string RET x="aaa...aaa" or something
>   like that, can you evaluate Python statements that are, say, 900 and
>   1100 characters long?


Will try this immediately

>


>
> >
> > I'm not an expert in how python.el internals work, but I started getting
> this error every time I would
> > send a statement to the shell. In addition I would get these weird
> printouts of blocks of the form
> >
> > ```
> >   def __PYDOC_get_help(obj):
> >     try:
> >         import inspect
> >         try:
> >             str_type = basestring
> >             argspec_function = inspect.getargspec
> >         except NameError:
> >             str_type = str
> > ```
> >
> > while just moving the point in my .py file.
> >
> > My current workaround was to simply override python-shell-send-string
> from 28.0.50 with the one
> > I had with my emacs 27 version, which was:
> >
> > ```
> > (defun python-shell-send-string (string &optional process msg)
> >   "Send STRING to inferior Python PROCESS.
> > When optional argument MSG is non-nil, forces display of a
> > user-friendly message if there's no process running; defaults to
> > t when called interactively."
> >   (interactive
> >    (list (read-string "Python command: ") nil t))
> >   (let ((process (or process (python-shell-get-process-or-error msg))))
> >     (if (string-match ".\n+." string)   ;Multiline.
> >         (let* ((temp-file-name (python-shell--save-temp-file string))
> >                (file-name (or (buffer-file-name) temp-file-name)))
> >           (python-shell-send-file file-name process temp-file-name t))
> >       (when (or (not (string-match "\n\\'" string))
> >                 (string-match "\n[ \t].*\n?\\'" string))
> >         (comint-send-string process "\n")))))
> > ```
> >
> > And this seems to solve the problem...
> >
> > In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.6.0, NS
> appkit-2022.60 Version 11.6
> > (Build 20G165))
> >  of 2021-09-17 built on mdfz-macbookpro4.roam.corp.google.com
> > Windowing system distributor 'Apple', version 10.3.2022
> > System Description:  macOS 11.6
> >
> > Configured using:
> >  'configure --disable-dependency-tracking --disable-silent-rules
> >  --enable-locallisppath=/usr/local/share/emacs/site-lisp
> >  --infodir=/usr/local/Cellar/emacs-plus <at> 28/28.0.50/share/info/emacs
> >  --prefix=/usr/local/Cellar/emacs-plus <at> 28/28.0.50 --with-xml2
> --with-gnutls
> >  --without-dbus --with-imagemagick --with-modules --with-rsvg --with-ns
> >  --disable-ns-self-contained'
> >
> > Configured features:
> > ACL GLIB GMP GNUTLS IMAGEMAGICK JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY
> KQUEUE
> > NS
> > PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM ZLIB
> >
> > Important settings:
> >   value of $LC_ALL: en_US.UTF-8
> >   value of $LC_CTYPE: en_US.UTF-8
> >   value of $LANG: en_US.UTF-8
> >   locale-coding-system: utf-8-unix
> >
> > Major mode: mu4e-headers
> >
> > Memory information:
> > ((conses 16 1905022 1639005)
> >  (symbols 48 123242 97)
> >  (strings 32 433582 151543)
> >  (string-bytes 1 14825386)
> >  (vectors 16 192606)
> >  (vector-slots 8 3165377 831342)
> >  (floats 8 1100 6586)
> >  (intervals 56 34684 19693)
> >  (buffers 992 60))
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50669; Package emacs. (Sun, 19 Sep 2021 09:44:01 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Michael-David Fiszer <sguibor <at> gmail.com>
Cc: 50669 <at> debbugs.gnu.org
Subject: Re: bug#50669: 28.0.50; python-shell-send-string leads to "nesting
 exceeds `max-lisp-eval-depth`" error
Date: Sun, 19 Sep 2021 11:42:56 +0200
On Sun, 19 Sep 2021 at 12:28, Michael-David Fiszer <sguibor <at> gmail.com> wrote:

> Hi!
>
> Thanks for the response!
>
> I'll fill in the details shortly. I wanted to add to the bug, that the functions being called repeatedly
> were `python-shell-send-string` and `python-shell-send-file`.
>
> They call one another and create more and more temporary files before I get the recursion error.
>

Are you on the current master?  These two functions used to be
entangled, but now only -send-string calls -send-file.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50669; Package emacs. (Sun, 19 Sep 2021 09:53:02 GMT) Full text and rfc822 format available.

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

From: Michael-David Fiszer <sguibor <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 50669 <at> debbugs.gnu.org
Subject: Re: bug#50669: 28.0.50; python-shell-send-string leads to "nesting
 exceeds `max-lisp-eval-depth`" error
Date: Sun, 19 Sep 2021 12:52:26 +0300
[Message part 1 (text/plain, inline)]
You are right. They are not calling one another (python-shell-send-file
calls comint). I think that it may that something is making them be called
one after another (my bad).

Backtrace looks like this (I changed the file name to `a_file_name` since
it's a company path)

  string-match-p("magit-.*: .*" "rider_now_utils.py")
  (not (string-match-p useless-regexp buf-name))
  (setq --cl-flag-- (not (string-match-p useless-regexp buf-name)))
  (progn (setq useless-regexp (car --cl-var--)) (setq --cl-flag-- (not
(string-match-p useless-regexp buf-name))))
  (and (consp --cl-var--) (progn (setq useless-regexp (car --cl-var--))
(setq --cl-flag-- (not (string-match-p useless-regexp buf-name)))))
  (while (and (consp --cl-var--) (progn (setq useless-regexp (car
--cl-var--)) (setq --cl-flag-- (not (string-match-p useless-regexp
buf-name))))) (setq --cl-var-- (cdr --cl-var--)))
  (let* ((--cl-var-- spacemacs-useless-buffers-regexp) (useless-regexp nil)
(--cl-flag-- t)) (while (and (consp --cl-var--) (progn (setq useless-regexp
(car --cl-var--)) (setq --cl-flag-- (not (string-match-p useless-regexp
buf-name))))) (setq --cl-var-- (cdr --cl-var--))) (if --cl-flag-- (progn t)
nil))
  (or (provided-mode-derived-p (buffer-local-value 'major-mode buffer)
'comint-mode) (let* ((--cl-var-- spacemacs-useful-buffers-regexp)
(useful-regexp nil) (--cl-flag-- t) --cl-var--) (while (and (consp
--cl-var--) (progn (setq useful-regexp (car --cl-var--)) (setq --cl-flag--
(not (setq --cl-var-- ...))))) (setq --cl-var-- (cdr --cl-var--)))
--cl-var--) (let* ((--cl-var-- spacemacs-useless-buffers-regexp)
(useless-regexp nil) (--cl-flag-- t)) (while (and (consp --cl-var--) (progn
(setq useless-regexp (car --cl-var--)) (setq --cl-flag-- (not
(string-match-p useless-regexp buf-name))))) (setq --cl-var-- (cdr
--cl-var--))) (if --cl-flag-- (progn t) nil)))
  (let ((buf-name (buffer-name buffer))) (or (provided-mode-derived-p
(buffer-local-value 'major-mode buffer) 'comint-mode) (let* ((--cl-var--
spacemacs-useful-buffers-regexp) (useful-regexp nil) (--cl-flag-- t)
--cl-var--) (while (and (consp --cl-var--) (progn (setq useful-regexp (car
--cl-var--)) (setq --cl-flag-- (not ...)))) (setq --cl-var-- (cdr
--cl-var--))) --cl-var--) (let* ((--cl-var--
spacemacs-useless-buffers-regexp) (useless-regexp nil) (--cl-flag-- t))
(while (and (consp --cl-var--) (progn (setq useless-regexp (car
--cl-var--)) (setq --cl-flag-- (not ...)))) (setq --cl-var-- (cdr
--cl-var--))) (if --cl-flag-- (progn t) nil))))
  spacemacs/useful-buffer-p(#<buffer rider_now_utils.py>)
  kill-buffer(#<buffer  *temp*-957895>)
  #f(compiled-function () #<bytecode -0x1c1e1505371ddc2b>)()
  python-shell-send-file("a_file_name..." #<process Python>
"/var/folders/gx/6fqj2t4x5tn4zml2qp9__9mr00j58f/T/p..." t)
  #f(compiled-function (string &optional process msg) "Send STRING to
inferior Python PROCESS.\nWhen optional argument MSG is non-nil, forces
display of a\nuser-friendly message if there's no process running; defaults
to\nt when called interactively." (interactive #f(compiled-function ()
#<bytecode 0x14ff04c703dd2bc5>)) #<bytecode -0x168dce9d6e1d8f8e>)("import
sys, codecs, os, ast;__pyfile = codecs.open..." #<process Python>)
  apply(#f(compiled-function (string &optional process msg) "Send STRING to
inferior Python PROCESS.\nWhen optional argument MSG is non-nil, forces
display of a\nuser-friendly message if there's no process running; defaults
to\nt when called interactively." (interactive #f(compiled-function ()
#<bytecode 0x14ff04c703dd2bc5>)) #<bytecode -0x168dce9d6e1d8f8e>) ("import
sys, codecs, os, ast;__pyfile = codecs.open..." #<process Python>))
  python-shell-send-string("import sys, codecs, os, ast;__pyfile =
codecs.open..." #<process Python>)
  python-shell-send-file("a_file_name..." #<process Python>
"/var/folders/gx/6fqj2t4x5tn4zml2qp9__9mr00j58f/T/p..." t)
  #f(compiled-function (string &optional process msg) "Send STRING to
inferior Python PROCESS.\nWhen optional argument MSG is non-nil, forces
display of a\nuser-friendly message if there's no process running; defaults
to\nt when called interactively." (interactive #f(compiled-function ()
#<bytecode 0x14ff04c703dd2bc5>)) #<bytecode -0x168dce9d6e1d8f8e>)("import
sys, codecs, os, ast;__pyfile = codecs.open..." #<process Python>)
  apply(#f(compiled-function (string &optional process msg) "Send STRING to
inferior Python PROCESS.\nWhen optional argument MSG is non-nil, forces
display of a\nuser-friendly message if there's no process running; defaults
to\nt when called interactively." (interactive #f(compiled-function ()
#<bytecode 0x14ff04c703dd2bc5>)) #<bytecode -0x168dce9d6e1d8f8e>) ("import
sys, codecs, os, ast;__pyfile = codecs.open..." #<process Python>))
  python-shell-send-string("import sys, codecs, os, ast;__pyfile =
codecs.open..." #<process Python>)
  python-shell-send-file("a_file_name..." #<process Python>
"/var/folders/gx/6fqj2t4x5tn4zml2qp9__9mr00j58f/T/p..." t)
  #f(compiled-function (string &optional process msg) "Send STRING to
inferior Python PROCESS.\nWhen optional argument MSG is non-nil, forces
display of a\nuser-friendly message if there's no process running; defaults
to\nt when called interactively." (interactive #f(compiled-function ()
#<bytecode 0x14ff04c703dd2bc5>)) #<bytecode -0x168dce9d6e1d8f8e>)("import
sys, codecs, os, ast;__pyfile = codecs.open..." #<process Python>)
  apply(#f(compiled-function (string &optional process msg) "Send STRING to
inferior Python PROCESS.\nWhen optional argument MSG is non-nil, forces
display of a\nuser-friendly message if there's no process running; defaults
to\nt when called interactively." (interactive #f(compiled-function ()
#<bytecode 0x14ff04c703dd2bc5>)) #<bytecode -0x168dce9d6e1d8f8e>) ("import
sys, codecs, os, ast;__pyfile = codecs.open..." #<process Python>))
  python-shell-send-string("import sys, codecs, os, ast;__pyfile =
codecs.open..." #<process Python>)
  python-shell-send-file("a_file_name..." #<process Python>
"/var/folders/gx/6fqj2t4x5tn4zml2qp9__9mr00j58f/T/p..." t)



On Sun, Sep 19, 2021 at 12:42 PM Augusto Stoffel <arstoffel <at> gmail.com>
wrote:

> On Sun, 19 Sep 2021 at 12:28, Michael-David Fiszer <sguibor <at> gmail.com>
> wrote:
>
> > Hi!
> >
> > Thanks for the response!
> >
> > I'll fill in the details shortly. I wanted to add to the bug, that the
> functions being called repeatedly
> > were `python-shell-send-string` and `python-shell-send-file`.
> >
> > They call one another and create more and more temporary files before I
> get the recursion error.
> >
>
> Are you on the current master?  These two functions used to be
> entangled, but now only -send-string calls -send-file.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50669; Package emacs. (Sun, 19 Sep 2021 10:37:02 GMT) Full text and rfc822 format available.

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

From: Michael-David Fiszer <sguibor <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 50669 <at> debbugs.gnu.org
Subject: Re: bug#50669: 28.0.50; python-shell-send-string leads to "nesting
 exceeds `max-lisp-eval-depth`" error
Date: Sun, 19 Sep 2021 13:36:33 +0300
[Message part 1 (text/plain, inline)]
Adding more details. BTW, no issues at all (none of the two, as it looks
like there may be two different issues) if I just do:

(advice-add 'python-shell-send-string :override
#'python-shell-send-string27)

where 'python-shell-send-string27 is the python-shell-send-string function
from emacs 27.2.

(regarding the backtrace, I realize it's hard to read - is there a better
way to send it formatted in this thread?)


On Sun, Sep 19, 2021 at 12:28 PM Michael-David Fiszer <sguibor <at> gmail.com>
wrote:

> Hi!
>
> Thanks for the response!
>
> I'll fill in the details shortly. I wanted to add to the bug, that the
> functions being called repeatedly were `python-shell-send-string` and
> `python-shell-send-file`.
>
> They call one another and create more and more temporary files before I
> get the recursion error.
>
> As a side note, python.el really rocks. Thanks so much for the amazing
> work.
>
> On Sun, Sep 19, 2021 at 12:10 PM Augusto Stoffel <arstoffel <at> gmail.com>
> wrote:
>
>> On Sun, 19 Sep 2021 at 03:32, Michael-David Fiszer <sguibor <at> gmail.com>
>> wrote:
>>
>> > Hi,
>>
>> Hi,
>>
>> Can you try 'M-x toggle-debug-on-error', or maybe tracing some
>> functions, to discover what is being called repeatedly?
>>
>> Also, what happens if you (setq python-eldoc-get-doc nil) in the .py
>> file's buffer?
>>
>
> I'll try this asap. I thought it was eldoc, but then tried turning off
> 'eldoc-mode' off and I still had the same problem with the infinite
> recursion (and I think I still saw the weird PYDOC strings, but not sure).
>
> But I will try this today.
>

This did not change anything to the nested lisp error, but does remove the
prints of "def __PYDOC_get_help(obj)". So it looks like there may have been
two different issues here.

>
>
>>
>> Some more macos-related things that would be helpful to know:
>>
>> * On a freshly started python-shell, is are the functions
>>   __PYTHON_EL_eval and __PYTHON_EL_eval_file defined?
>>
>
> I just checked, and they both are.
>
> <function __main__.__PYTHON_EL_eval(source, filename)>
> <function __main__.__PYTHON_EL_eval_file(filename, tempname, delete)>
>
>>
>> * If you do M-x python-shell-send-string RET x="aaa...aaa" or something
>>   like that, can you evaluate Python statements that are, say, 900 and
>>   1100 characters long?
>
>
> Will try this immediately
>

So, interesting, if I write

x = "aaa....a" in my py file (calling python-shell-send-string
interactively doesn't work like that, shoud it?), it works for len(x) = 422
and not for len(x)=423 (same error "nesting exceeds").


>
>
>
>>
>> >
>> > I'm not an expert in how python.el internals work, but I started
>> getting this error every time I would
>> > send a statement to the shell. In addition I would get these weird
>> printouts of blocks of the form
>> >
>> > ```
>> >   def __PYDOC_get_help(obj):
>> >     try:
>> >         import inspect
>> >         try:
>> >             str_type = basestring
>> >             argspec_function = inspect.getargspec
>> >         except NameError:
>> >             str_type = str
>> > ```
>> >
>> > while just moving the point in my .py file.
>> >
>> > My current workaround was to simply override python-shell-send-string
>> from 28.0.50 with the one
>> > I had with my emacs 27 version, which was:
>> >
>> > ```
>> > (defun python-shell-send-string (string &optional process msg)
>> >   "Send STRING to inferior Python PROCESS.
>> > When optional argument MSG is non-nil, forces display of a
>> > user-friendly message if there's no process running; defaults to
>> > t when called interactively."
>> >   (interactive
>> >    (list (read-string "Python command: ") nil t))
>> >   (let ((process (or process (python-shell-get-process-or-error msg))))
>> >     (if (string-match ".\n+." string)   ;Multiline.
>> >         (let* ((temp-file-name (python-shell--save-temp-file string))
>> >                (file-name (or (buffer-file-name) temp-file-name)))
>> >           (python-shell-send-file file-name process temp-file-name t))
>> >       (when (or (not (string-match "\n\\'" string))
>> >                 (string-match "\n[ \t].*\n?\\'" string))
>> >         (comint-send-string process "\n")))))
>> > ```
>> >
>> > And this seems to solve the problem...
>> >
>> > In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.6.0, NS
>> appkit-2022.60 Version 11.6
>> > (Build 20G165))
>> >  of 2021-09-17 built on mdfz-macbookpro4.roam.corp.google.com
>> > Windowing system distributor 'Apple', version 10.3.2022
>> > System Description:  macOS 11.6
>> >
>> > Configured using:
>> >  'configure --disable-dependency-tracking --disable-silent-rules
>> >  --enable-locallisppath=/usr/local/share/emacs/site-lisp
>> >  --infodir=/usr/local/Cellar/emacs-plus <at> 28/28.0.50/share/info/emacs
>> >  --prefix=/usr/local/Cellar/emacs-plus <at> 28/28.0.50 --with-xml2
>> --with-gnutls
>> >  --without-dbus --with-imagemagick --with-modules --with-rsvg --with-ns
>> >  --disable-ns-self-contained'
>> >
>> > Configured features:
>> > ACL GLIB GMP GNUTLS IMAGEMAGICK JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY
>> KQUEUE
>> > NS
>> > PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM ZLIB
>> >
>> > Important settings:
>> >   value of $LC_ALL: en_US.UTF-8
>> >   value of $LC_CTYPE: en_US.UTF-8
>> >   value of $LANG: en_US.UTF-8
>> >   locale-coding-system: utf-8-unix
>> >
>> > Major mode: mu4e-headers
>> >
>> > Memory information:
>> > ((conses 16 1905022 1639005)
>> >  (symbols 48 123242 97)
>> >  (strings 32 433582 151543)
>> >  (string-bytes 1 14825386)
>> >  (vectors 16 192606)
>> >  (vector-slots 8 3165377 831342)
>> >  (floats 8 1100 6586)
>> >  (intervals 56 34684 19693)
>> >  (buffers 992 60))
>>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50669; Package emacs. (Sun, 19 Sep 2021 16:14:01 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Michael-David Fiszer <sguibor <at> gmail.com>
Cc: 50669 <at> debbugs.gnu.org
Subject: Re: bug#50669: 28.0.50; python-shell-send-string leads to "nesting
 exceeds `max-lisp-eval-depth`" error
Date: Sun, 19 Sep 2021 18:12:59 +0200
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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50669; Package emacs. (Tue, 21 Sep 2021 21:18:02 GMT) Full text and rfc822 format available.

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

From: Michael-David Fiszer <sguibor <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 50669 <at> debbugs.gnu.org
Subject: Re: bug#50669: 28.0.50; python-shell-send-string leads to "nesting
 exceeds `max-lisp-eval-depth`" error
Date: Wed, 22 Sep 2021 00:17:27 +0300
[Message part 1 (text/plain, inline)]
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 <arstoffel <at> gmail.com> 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?
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50669; Package emacs. (Fri, 26 Aug 2022 11:48:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael-David Fiszer <sguibor <at> gmail.com>
Cc: 50669 <at> debbugs.gnu.org
Subject: Re: bug#50669: 28.0.50; python-shell-send-string leads to "nesting
 exceeds `max-lisp-eval-depth`" error
Date: Fri, 26 Aug 2022 13:46:57 +0200
Michael-David Fiszer <sguibor <at> gmail.com> writes:

> I'm not an expert in how python.el internals work, but I started
> getting this error every time I would send a statement to the
> shell. In addition I would get these weird printouts of blocks of the
> form

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Are you still seeing these issues with the current Emacs "master"
branch?  There's been quite a lot of work done in this area over the
last year.





Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 26 Aug 2022 11:48:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50669; Package emacs. (Sat, 24 Sep 2022 15:00:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael-David Fiszer <sguibor <at> gmail.com>
Cc: 50669 <at> debbugs.gnu.org
Subject: Re: bug#50669: 28.0.50; python-shell-send-string leads to "nesting
 exceeds `max-lisp-eval-depth`" error
Date: Sat, 24 Sep 2022 16:59:15 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Are you still seeing these issues with the current Emacs "master"
> branch?  There's been quite a lot of work done in this area over the
> last year.

More information was requested, but no response was given within a
month, so I'm closing this bug report.  If the problem still exists,
please respond to this email and we'll reopen the bug report.




bug closed, send any further explanations to 50669 <at> debbugs.gnu.org and Michael-David Fiszer <sguibor <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 24 Sep 2022 15:00:04 GMT) Full text and rfc822 format available.

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

This bug report was last modified 1 year and 184 days ago.

Previous Next


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