From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: kobarity Newsgroups: gmane.emacs.bugs Subject: bug#71440: Python Inferior Mode =?UTF-8?Q?Can=E2=80=99t?= Recognize My Prompt Date: Mon, 10 Jun 2024 00:26:50 +0900 Message-ID: References: <86sexnbckv.fsf@gnu.org> <86r0d7bawc.fsf@gnu.org> <86ikyjb7ky.fsf@gnu.org> <86h6e2buul.fsf@gnu.org> <8634pmbefs.fsf@gnu.org> <86y17e9y5p.fsf@gnu.org> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: multipart/mixed; boundary="Multipart_Mon_Jun_10_00:26:50_2024-1" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21175"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: 71440@debbugs.gnu.org To: "shynur ." , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 09 17:28:54 2024 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 1sGKTU-0005Is-Rn for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Jun 2024 17:28:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGKTP-0004mc-9N; Sun, 09 Jun 2024 11:28:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGKTN-0004mG-FY for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2024 11:28:45 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGKTN-0002vC-7T for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2024 11:28:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sGKTd-0002Qg-Jt for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2024 11:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Jun 2024 15:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71440 X-GNU-PR-Package: emacs Original-Received: via spool by 71440-submit@debbugs.gnu.org id=B71440.17179468999209 (code B ref 71440); Sun, 09 Jun 2024 15:29:01 +0000 Original-Received: (at 71440) by debbugs.gnu.org; 9 Jun 2024 15:28:19 +0000 Original-Received: from localhost ([127.0.0.1]:44553 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sGKSx-0002OS-1u for submit@debbugs.gnu.org; Sun, 09 Jun 2024 11:28:19 -0400 Original-Received: from mail-pl1-f174.google.com ([209.85.214.174]:60480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sGKSv-0002O8-CV for 71440@debbugs.gnu.org; Sun, 09 Jun 2024 11:28:18 -0400 Original-Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1f6dfc17006so13453135ad.0 for <71440@debbugs.gnu.org>; Sun, 09 Jun 2024 08:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717946815; x=1718551615; darn=debbugs.gnu.org; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=SoYD71NCvbtPjzQngnyQxSSWXvDGeRnx8l0Rt5IIFmU=; b=mWIlLv9Es1YltWg3hze+22mI5evvpGgCBKhGrgc9Bb1YkqjHXmt/BrwtEgWZQ3yFya mn8B4/GbP4lIJ48MjKH/d6hqFEosU/F0h0leUTJ7rBI9CMJCIPfP7i4qnAi7qsbRkOWK JtG9SKmOCWBQ8mvu2NK0gRT1Doxe4PrNskPwe3iNfmTu7Iwu54rU7hTfPwu6V1dWQRi6 L3SmyjFbAQi4s0FMCEK7zqVv7As1FSJ+NxNto8Hj5afzIXSNE9sEb9YFvS8UEZVre2oG Tpjx/su3wsJ499jEIoMnUeTnHneVm9B7qgEkBXGJ0F0ODq+FDUeHhFRxmffSYKmEicaB DPZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717946815; x=1718551615; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SoYD71NCvbtPjzQngnyQxSSWXvDGeRnx8l0Rt5IIFmU=; b=J7jdEYadUW+E7M9bma3Grom/OBccraa29G+0uX8dEAwBg99ZjNCGfocd/+lzNswv6z Az+WMzs/KtB0PDqzQ4zZx23cYW7aZAED/ahVEB0fgq07/VqLZHmGLQ8LkvzHBsVk0PhH gehPNf9F8C2jYVb/ctbSVTPI4J1Dmwmlac1q0im+2ANOCDfOCKYXMv/equ5VldJ7/uiV eP1mu59F2dtkh7u/V7mXHgvEYFixOffbnK1/0whnRKvEfEZ7AXGadT8Gyi2ETzSphhUS G2QyvD5yz/ypiXkbmuRAT6KZ1GJVjTg116eUztIjqD6RIVo/e12sv1MQtn7pvPNhLMGE vt0A== X-Gm-Message-State: AOJu0Yxrh9OH/JxGX8Qvx13A3YmpaVPbRN9tPQsoODbAQAPr+VHvcVvZ w6hu/A5jNuwCVgLLG73vr2eQhX+9euYDoCOzv/nWpB9rJ+F9NF5e X-Google-Smtp-Source: AGHT+IF/A5wcxaiCMpBWfiLg07pgpHheD17i6x7oYXh/OKCx+3h7A4MatjV/ZvINNymdXpkulW44Og== X-Received: by 2002:a17:902:ecc9:b0:1f6:f521:ff88 with SMTP id d9443c01a7336-1f6f522029emr30450685ad.23.1717946814733; Sun, 09 Jun 2024 08:26:54 -0700 (PDT) Original-Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f709733ecbsm10624225ad.277.2024.06.09.08.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 08:26:54 -0700 (PDT) In-Reply-To: <86y17e9y5p.fsf@gnu.org> 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286948 Archived-At: --Multipart_Mon_Jun_10_00:26:50_2024-1 Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable Eli Zaretskii wrote: >=20 > > From: "shynur ." > > CC: "71440@debbugs.gnu.org" <71440@debbugs.gnu.org> > > Date: Sun, 9 Jun 2024 10:49:19 +0000 > > msip_labels: > >=20 > > > I wonder how PS1 and PS2 are at all relevant when using=20 > > > python-shell-send-buffer? That function sends the buffer > > > text to Python, so where do PS1 and PS2 come into play, > > > and why does Python say "__PYTHON_EL_eval is not defined"=20 > > > just because you have PS1 and PS2 customized? > >=20 > > I know it=A2s *weird* but it just happened. > > I gave the recipes in the original post for anyone to=20 > > reproduce it. > >=20 > > > If someone helps me understand that, maybe I will have=20 > > > further ideas. > >=20 > > How about CC this post to the maintainer(s) of =A1python.el=A2? >=20 > Done. >=20 > > > How about defining PYTHONSTARTUP to point to a different=20 > > > file? > >=20 > > This makes it inconvenient to add or modify content to the=20 > > =A1PYTHONSTARTUP=A2 file because each change needs to be synced > > to another file that exists for Emacs. >=20 > You are on Windows, so some measure of inconvenience is expected. Seems like a bug or limitation in `python-shell-prompt-detect'. Can you try the attached diff? It should work with Python 2.6 or higher. --Multipart_Mon_Jun_10_00:26:50_2024-1 Content-Type: application/octet-stream; type=patch; name="71440.diff" Content-Disposition: attachment; filename="71440.diff" Content-Transfer-Encoding: 7bit diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index bb2bf1731b4..14e4ba1c6cc 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3102,10 +3102,9 @@ python-shell-prompt-detect (when python-shell-prompt-detect-enabled (python-shell-with-environment (let* ((code (concat - "import sys\n" + "import json, sys\n" "ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]\n" - ;; JSON is built manually for compatibility - "ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps)\n" + "ps_json = json.dumps(ps)\n" "print (ps_json)\n" "sys.exit(0)\n")) (interpreter python-shell-interpreter) @@ -3168,7 +3167,7 @@ python-shell-prompt-detect "Or alternatively in:\n" " + `python-shell-prompt-input-regexps'\n" " + `python-shell-prompt-output-regexps'"))) - prompts)))) + (mapcar #'ansi-color-filter-apply prompts))))) (defun python-shell-prompt-validate-regexps () "Validate all user provided regexps for prompts. --Multipart_Mon_Jun_10_00:26:50_2024-1--