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 12:28:04 +0300 Message-ID: References: <87zgs9gcd3.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000cdf07505cc55c840" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16385"; 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 11:29:13 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 1mRt8L-00045m-31 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 11:29:13 +0200 Original-Received: from localhost ([::1]:32786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRt8J-00060p-5R for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 05:29:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRt8B-00060g-11 for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 05:29:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRt8A-0008Is-KV for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 05:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mRt8A-0007S7-Au for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 05:29: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 09:29: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.163204370428598 (code B ref 50669); Sun, 19 Sep 2021 09:29:02 +0000 Original-Received: (at 50669) by debbugs.gnu.org; 19 Sep 2021 09:28:24 +0000 Original-Received: from localhost ([127.0.0.1]:37472 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRt7X-0007RB-Vq for submit@debbugs.gnu.org; Sun, 19 Sep 2021 05:28:24 -0400 Original-Received: from mail-vs1-f52.google.com ([209.85.217.52]:44012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRt7W-0007Qy-FY for 50669@debbugs.gnu.org; Sun, 19 Sep 2021 05:28:23 -0400 Original-Received: by mail-vs1-f52.google.com with SMTP id n17so13022829vsr.10 for <50669@debbugs.gnu.org>; Sun, 19 Sep 2021 02:28:22 -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=F8n/BYZmUfNcQPLwsttELMzGgG2krdw0gaoTWK9EYJs=; b=fHUjkfsquqJHqOZ4WlTHtb2DPiecyJJGmo29mr1ZOiCS6J2OPOXoBCvbSk2QupbmhM HJovN1oBkmhJDxQfpx96ezVl3KcOMkaGTZ9I7xWiv8D0wsaJ7TLWWqbrlcPg8LdOa2Wj birVouwwQfLv2mL6LYYKF0U4KYbj9xpHytW8TKRnVYxTNsK/1nVhxsGgHyagvzWcQ9l3 KBJRKeK7mvHW2X+XJi3BeFgV6tPsO+wOYzRmzcxbKSm8SGfdL8gz9+0bojiAHjAB+Jyk sNaz/hQJxQNFmlCBQ7MCGX2BcmYhlc+xehkZXILN2uCfx/sdkFHs6dB5iZ34LKWuSwY0 tk9w== 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=F8n/BYZmUfNcQPLwsttELMzGgG2krdw0gaoTWK9EYJs=; b=lpj5JgccmdGAcoQyNOmAWy1MSpGmEqNxbBkbdI9aASWlY5yk9dvoCc1uASQYY8R9SB btwXI0TDs2cneFp5BBiYJjXwBOvx9RlsXXA+0XGibFI+tah/hJw+9HSIGwlgqfNyl42Y 4OkYpiR2SKVAUdybAjzFR2yWNlsfEJpE8Pdae9WPjiB5idFfOqSwMEDP+6GeufJyS5uR bWrzMhfHEy4oSfP/sPr2s+TN/0iI4rTWWrY/6qeGnPYIr8yovpxEvLp40X4FL51X8JGx 8Zv38ME5I7Sh0WHu+EmsiKXa7J5rrPLETrcuV1NXUTjkIP37jqHCjvd7b4SNdxkcJ6Ct 5Yyw== X-Gm-Message-State: AOAM5305VNRWRYOlZgpyT7sAJ+HEM3YdmF9Dw2Q7+ci7pwU0d9Sl3F4c 4noR7fVlNCEBprGwzKJfQm0gr0Yowvl/GJU5hpI= X-Google-Smtp-Source: ABdhPJwpotb4MGZyn1uRf3P7NMZXetPFeT+l0WmkRPXOaCQihJ3gmfasnQjMnclABm86G61zMz9C+1GNlrf6Uq4TBM4= X-Received: by 2002:a67:441:: with SMTP id 62mr13538278vse.54.1632043696777; Sun, 19 Sep 2021 02:28:16 -0700 (PDT) In-Reply-To: <87zgs9gcd3.fsf@gmail.com> 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:214694 Archived-At: --000000000000cdf07505cc55c840 Content-Type: text/plain; charset="UTF-8" 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. > > 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 > > > > > > 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)) > --000000000000cdf07505cc55c840 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi!

Thanks for the res= ponse!

I'll fill in the details shortly. I wan= ted to add to the bug, that the functions being called repeatedly were `pyt= hon-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, 20= 21 at 12:10 PM Augusto Stoffel <a= rstoffel@gmail.com> wrote:
On Sun, 19 Sep 2021 at 03:32, Michael-David Fiszer <sguibor@gmail.com&= gt; 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.
=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
= =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))
--000000000000cdf07505cc55c840--