From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#49822: [RFC PATCH] python-shell-send functions show no output Date: Sat, 28 Aug 2021 17:41:20 +0200 Message-ID: <87o89hinkv.fsf@gnus.org> References: <855f9eaf1b1d39bb9325d0a88e7f66c0ba0b45d0.camel@gmail.com> <87r1f9fzj4.fsf@gnus.org> <87im0a6789.fsf@gmail.com> <8735rdha6y.fsf@gnus.org> <69e713da-5186-780a-f0b7-8099ce6cde3d@easy-emacs.de> <87h7fsnzmo.fsf@gmail.com> <51fa5c12-53b4-ad92-505f-1896d955b68c@easy-emacs.de> <87k0k8wqyo.fsf@gmail.com> <87h7fc1enm.fsf@gnus.org> <87sfytex5b.fsf_-_@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37777"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 49822@debbugs.gnu.org To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 28 17:42:39 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 1mK0Tf-0009et-2O for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Aug 2021 17:42:39 +0200 Original-Received: from localhost ([::1]:43328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mK0Td-0001Es-Ug for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Aug 2021 11:42:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mK0T4-0001Dr-R2 for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 11:42:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43309) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mK0T4-0006RL-Ik for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 11:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mK0T4-0006Xl-Eg for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 11:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Aug 2021 15:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49822 X-GNU-PR-Package: emacs Original-Received: via spool by 49822-submit@debbugs.gnu.org id=B49822.163016529425097 (code B ref 49822); Sat, 28 Aug 2021 15:42:02 +0000 Original-Received: (at 49822) by debbugs.gnu.org; 28 Aug 2021 15:41:34 +0000 Original-Received: from localhost ([127.0.0.1]:54852 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mK0Sc-0006Wi-H8 for submit@debbugs.gnu.org; Sat, 28 Aug 2021 11:41:34 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:44034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mK0Sa-0006WR-VH for 49822@debbugs.gnu.org; Sat, 28 Aug 2021 11:41:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=nPkmzfP0N4iWxX+8UkWAc1tgd2iiEf1BDWlR/uSFmLo=; b=akR1nL4kxzs+iwImtyxay5sYDn y7a/cRVMgXAXJlsrV813rHc+M0YdQMmte4upIR4V//5mv3gKqWljZisLOVH6HY0sO9vWpJKWRyRJq GlpE0Pwu1uPDFiM83+nKvtnMwwwSGlF03YD/XNP5COkZwfuBSgYPpZmpQ1SzIa0dIXOc=; Original-Received: from [84.212.220.105] (helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mK0SQ-00053k-67; Sat, 28 Aug 2021 17:41:26 +0200 In-Reply-To: <87sfytex5b.fsf_-_@gmail.com> (Augusto Stoffel's message of "Sat, 28 Aug 2021 11:28:16 +0200") 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:212877 Archived-At: Augusto Stoffel writes: > The main user-visible change is that now a result is printed in the > shell in all possible cases, i.e.: > > 1. If the string being evaluated is a one-line expression. > 2. If the string being evaluated is a multiline expression such as > "(1+\n1)". > 3. The string being evaluated is contains multiple statements, the last > of which is an expression. E.g., "x=1\nx". > > Currently, only case 1 prints a result (this is the actual topic of this > bug). Sounds like a definite improvement. :-) > This is a reasonably sensitive change and it would be good to collect > feedback from others before merging it (a properly formatted patch will > then follow). In particular, since I'm not an expert in Python's > internals, there might be some possible refinements to the > __PYTHON_EL_eval function. Is this perhaps a better topic for the > emacs-devel list? Yes, it might be a good idea to raise this topic on emacs-devel and see if there's any feedback. Some minor comments on the patch: > +(defvar python-shell-eval-setup-code > + "\ > +def __PYTHON_EL_eval(source, filename): > + import ast, sys > + if sys.version_info[0] == 2: > + from __builtin__ import compile, eval, globals I think it might be a better long-term maintenance solution to put the Python code here (and from `python-shell-completion-native-setup') into a .py file under etc (for instance in a new "python-mode" sub-directory), and then read it in run-time (accessed via `data-directory', which points to etc), and cache it in an internal variable. Editing Python that's inside a Lisp string is awkward. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no