From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael-David Fiszer Newsgroups: gmane.emacs.bugs Subject: 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-ID: References: <87zgs9gcd3.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000a8fc0a05cc56bd4b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3675"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 50669@debbugs.gnu.org To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 19 12:37:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mRuC7-0000nG-AA for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 12:37:11 +0200 Original-Received: from localhost ([::1]:53674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRuC6-0006N4-1u for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 06:37:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRuBy-0006Mg-PY for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 06:37:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54213) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRuBy-00079O-Hw for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 06:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mRuBy-0000xn-DK for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 06:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael-David Fiszer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Sep 2021 10:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50669 X-GNU-PR-Package: emacs Original-Received: via spool by 50669-submit@debbugs.gnu.org id=B50669.16320478133685 (code B ref 50669); Sun, 19 Sep 2021 10:37:02 +0000 Original-Received: (at 50669) by debbugs.gnu.org; 19 Sep 2021 10:36:53 +0000 Original-Received: from localhost ([127.0.0.1]:37526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRuBp-0000xN-7m for submit@debbugs.gnu.org; Sun, 19 Sep 2021 06:36:53 -0400 Original-Received: from mail-ua1-f49.google.com ([209.85.222.49]:34350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRuBm-0000x6-F5 for 50669@debbugs.gnu.org; Sun, 19 Sep 2021 06:36:51 -0400 Original-Received: by mail-ua1-f49.google.com with SMTP id v9so9154438uak.1 for <50669@debbugs.gnu.org>; Sun, 19 Sep 2021 03:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ie7u0houRSExGG/wT4Wjt5EArmLVfHi08tD89clbI1k=; b=FFUZDvDEko+tsufemB32b/lYzngfeimHl2DRd/AmB+D+9GdNNjMzTFy6sWVdBIkiyh UQBZlO+kA/aaP+6TTrYK1UDL8/9b0iVvLiuZfMkZnWzTje49+2Os6Z7leswA+tIIiKCW 83LaeF6F2at6esmopKU/B+9u8D+RT0Ful+vJodzKsxC3WXCKZa7seURpyiHKb2DJ90BI WNcUdSw8wx7+96gHGZzjle/RJIhdeP1LAFBAOdKBQuxG1+cs0IY8HQzAnryDrIOJ0iYw 1o8/ZnMS2RNFT7T23S1S+uuJ9vT1okgFu5KYSwMiejBM1V1kFhtPK7tG3vejzjQ08UCW 1hbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ie7u0houRSExGG/wT4Wjt5EArmLVfHi08tD89clbI1k=; b=36CCjNv+CHiil5R0m9Al0uTxa9GE36rjnKZUuCgcXGHT18ezm07duNscKG5C3qGAMs T3d+gfwAf+6SuT1f244TovQ5F2MViv+/yUomillXnL3vUJZgczmOtPNTHHkRIYKuNHEE F8J6Vb+yp4l2u7QCoSTXIA/wz5ar+usLN7jX0q2ZAIwEq97sIUQDcqG9qMIby0HpB3Bd mDXJANRZKNZS0+muQT8PeyqPCZlFj0v6g8mI3TECCbtzUw6FG9NNfS1Em0BVAbUxfs+T 2yDuRcVWag+ij7YAZngPlMgOijce9qtfTxTnSVOBvCKbKnA5diRx8H8f3SvAn9+/GXGi gpqA== X-Gm-Message-State: AOAM5331AbaiYD8cxBgV8j1fqDLuWcf3i+EpHsOqsTIfelUWyvgs4DFR 5o++PC+gOnQsiMQ2oGmF5tgmzatjFHicoxkelwtukMVN X-Google-Smtp-Source: ABdhPJzEVQKsGNEoz/kMuTBdi9OHpgeEI3S9BfjX3dNLLJCeqVVEfZU102U1/fTgfr/amfV7TUN8NrCZtI5OkG+/JNQ= X-Received: by 2002:a9f:309d:: with SMTP id j29mr932022uab.38.1632047804774; Sun, 19 Sep 2021 03:36:44 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214699 Archived-At: --000000000000a8fc0a05cc56bd4b Content-Type: text/plain; charset="UTF-8" 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 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 > wrote: > >> On Sun, 19 Sep 2021 at 03:32, Michael-David Fiszer >> 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. > > > > >> >> * 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@28/28.0.50/share/info/emacs >> > --prefix=/usr/local/Cellar/emacs-plus@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)) >> > --000000000000a8fc0a05cc56bd4b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Adding more details. BTW, no issues at al= l (none of the two, as it looks like there may be two different issues) if = I just do:

(advice-add 'python-shell-send-stri= ng :override #'python-shell-send-string27)

where 'python-shell-send-string27 is the python-shell-send-string func= tion 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-Dav= id Fiszer <sguibo= r@gmail.com> wrote:
Hi!

Thanks = for the response!

I'll fill in the details sho= rtly. I wanted to add to the bug, that the functions being called repeatedl= y were `python-shell-send-string` and `python-shell-send-file`.
<= br>
They call one another and create more and more temporary file= s before I get the recursion error.

As a side note= , python.el really rocks. Thanks so much for the amazing work.
<= br>
On Sun,= Sep 19, 2021 at 12:10 PM Augusto Stoffel <arstoffel@gmail.com> wrote:
On Sun, 19 Sep 2021 at 03:32= , Michael-David Fiszer <sguibor@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 as= ap. 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 th= ink I still saw the weird=C2=A0PYDOC strings, but not sure).

=
But I will try this today.
This did not change anything to the nested lisp error, but doe= s remove the prints of "def __PYDOC_get_help(obj)". So it looks l= ike there may have been two different issues here.
=C2=A0

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

* On a freshly started python-shell, is are the functions
=C2=A0 __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=3D"aaa...aaa" or s= omething
=C2=A0 like that, can you evaluate Python statements that are, say, 900 and=
=C2=A0 1100 characters long?

Will try this = immediately=C2=A0

So, int= eresting, if I write

x =3D "aaa....a" in= my py file (calling python-shell-send-string interactively doesn't wor= k like that, shoud it?), it works for len(x) =3D 422 and not for len(x)=3D4= 23 (same error "nesting exceeds").
=C2=A0
=C2=A0


>
> I'm not an expert in how python.el internals work, but I started g= etting this error every time I would
> send a statement to the shell. In addition I would get these weird pri= ntouts of blocks of the form
>
> ```
>=C2=A0 =C2=A0def __PYDOC_get_help(obj):
>=C2=A0 =C2=A0 =C2=A0try:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0import inspect
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0try:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0str_type =3D basestring=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0argspec_function =3D in= spect.getargspec
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0except NameError:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0str_type =3D 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)
>=C2=A0 =C2=A0"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."
>=C2=A0 =C2=A0(interactive
>=C2=A0 =C2=A0 (list (read-string "Python command: ") nil t))<= br> >=C2=A0 =C2=A0(let ((process (or process (python-shell-get-process-or-er= ror msg))))
>=C2=A0 =C2=A0 =C2=A0(if (string-match ".\n+." string)=C2=A0 = =C2=A0;Multiline.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let* ((temp-file-name (python-shell-= -save-temp-file string))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (file-name (or = (buffer-file-name) temp-file-name)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(python-shell-send-file file-n= ame process temp-file-name t))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(when (or (not (string-match "\n\\'= " string))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(string-m= atch "\n[ \t].*\n?\\'" string))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(comint-send-string process "\n&= quot;)))))
> ```
>
> And this seems to solve the problem...
>
> In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.6.0, NS appkit-20= 22.60 Version 11.6
> (Build 20G165))
>=C2=A0 of 2021-09-17 built on mdfz-macbookpro4.roam.= corp.google.com
> Windowing system distributor 'Apple', version 10.3.2022
> System Description:=C2=A0 macOS 11.6
>
> Configured using:
>=C2=A0 'configure --disable-dependency-tracking --disable-silent-ru= les
>=C2=A0 --enable-locallisppath=3D/usr/local/share/emacs/site-lisp
>=C2=A0 --infodir=3D/usr/local/Cellar/emacs-plus@28/28.0.50/share/info/e= macs
>=C2=A0 --prefix=3D/usr/local/Cellar/emacs-plus@28/28.0.50 --with-xml2 -= -with-gnutls
>=C2=A0 --without-dbus --with-imagemagick --with-modules --with-rsvg --w= ith-ns
>=C2=A0 --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:
>=C2=A0 =C2=A0value of $LC_ALL: en_US.UTF-8
>=C2=A0 =C2=A0value of $LC_CTYPE: en_US.UTF-8
>=C2=A0 =C2=A0value of $LANG: en_US.UTF-8
>=C2=A0 =C2=A0locale-coding-system: utf-8-unix
>
> Major mode: mu4e-headers
>
> Memory information:
> ((conses 16 1905022 1639005)
>=C2=A0 (symbols 48 123242 97)
>=C2=A0 (strings 32 433582 151543)
>=C2=A0 (string-bytes 1 14825386)
>=C2=A0 (vectors 16 192606)
>=C2=A0 (vector-slots 8 3165377 831342)
>=C2=A0 (floats 8 1100 6586)
>=C2=A0 (intervals 56 34684 19693)
>=C2=A0 (buffers 992 60))
--000000000000a8fc0a05cc56bd4b--