From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ben Sturmfels via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#29592: 25.3; python does not print input or output in the inferior process Date: Sat, 26 Feb 2022 10:00:35 +1100 Message-ID: <87tucmft64.fsf@sturm.com.au> References: <87indjel8l.fsf@gmail.com> <8735k6obhp.fsf@sturm.com.au> Reply-To: Ben Sturmfels Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13765"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cc: 29592@debbugs.gnu.org To: Alex Branham Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 26 00:01:49 2022 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 1nNjau-0003Jz-7c for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Feb 2022 00:01:49 +0100 Original-Received: from localhost ([::1]:41548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNjas-0002ff-O1 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Feb 2022 18:01:46 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNjaA-0002dd-J8 for bug-gnu-emacs@gnu.org; Fri, 25 Feb 2022 18:01:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nNjaA-0007Dq-1K for bug-gnu-emacs@gnu.org; Fri, 25 Feb 2022 18:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nNja9-0004YN-TO for bug-gnu-emacs@gnu.org; Fri, 25 Feb 2022 18:01:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ben Sturmfels Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Feb 2022 23:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29592 X-GNU-PR-Package: emacs Original-Received: via spool by 29592-submit@debbugs.gnu.org id=B29592.164583005917487 (code B ref 29592); Fri, 25 Feb 2022 23:01:01 +0000 Original-Received: (at 29592) by debbugs.gnu.org; 25 Feb 2022 23:00:59 +0000 Original-Received: from localhost ([127.0.0.1]:53900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nNja6-0004Xy-GL for submit@debbugs.gnu.org; Fri, 25 Feb 2022 18:00:58 -0500 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:54963) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nNja3-0004Xg-RI for 29592@debbugs.gnu.org; Fri, 25 Feb 2022 18:00:57 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 7CC4C5C024A; Fri, 25 Feb 2022 18:00:49 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 25 Feb 2022 18:00:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sturm.com.au; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; bh=rKIQTV3l+smjneK+XqHa4gh9WDegj1SQPsgE0q LcKgs=; b=NMpjkQyBBwCwvtJUYM+xy9DXKmh4aJH6I3wrzeHWFLwSonOsOWsOET EmrUjDZjC6tKmoKVufWs5rVH7vgMGFSyp9iTQLdPvGljz78hQBTlQp+hmqfjlLQ7 vViIuMEZOM2yGziA57ZKMOTtJXrD3Brf3XySpwonQPr4y146XbnF0rcqYHxjkclc n65wC1Oqf6E3gokq0C9z9eA416plKO0k6D/BTr/IZ+u3mgyF3WO2uU+y2m5UZugB F2wInj42g5VkeBiIs9Tc/9k1KDepW6nd014TzwSuBAmf40bvihwoMufxMUAGcSoR 95LamUFM7Lw8iqxazQHV3MfqdZ+x0+Fw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=rKIQTV3l+smjneK+X qHa4gh9WDegj1SQPsgE0qLcKgs=; b=WZsxxIXdMt1GRkxAc6ic5AccAwo68p9cl PaSJ3aM074TwxmIrAFO1KjsoKvYp51TjlcZX+meloqJJ8Bb66/lXKyPUUajI4KwN westQdW7mtdk2ievjTgQKV+vqiiGHw+Uyx/MzdljC3j3QM33KrEX1V4hqour6w7a zb4yh8WIwcE1FADfPhrCyRB6LOKPtzduDVmeatv2aD7OGyLJQGCm9PU8Pm0ZluLW xSBVLOV0014vSm16m9HngG6iDjO5yeqiWeP26im3ZUm3alk9phnVTzjXngmJ01VG cQPdNwba59NTmhQY7UgeT5WJaCy9P7oKBZwwd206uTZrAQhYQe7Mg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrleehgddtfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufhffjgfkfgggtgesthdtredttdertdenucfhrhhomhepuegvnhcuufht uhhrmhhfvghlshcuoegsvghnsehsthhurhhmrdgtohhmrdgruheqnecuggftrfgrthhtvg hrnhepfeeghefggfeludeiieethfefgfffhfduffeklefgieduieetjefhfeetfeejudef necuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpegsvghnsehsthhurhhmrdgtohhmrdgruh X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 25 Feb 2022 18:00:47 -0500 (EST) Original-Received: from Marseille (localhost.lan [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 85df966b; Fri, 25 Feb 2022 23:00:45 +0000 (UTC) In-Reply-To: <8735k6obhp.fsf@sturm.com.au> (Ben Sturmfels's message of "Sat, 26 Feb 2022 08:57:38 +1100") 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:227655 Archived-At: The GitHub ticket below for elpy also mentions this issue and includes some "quick-and-dirty" that does seem to address the issue. The code works, but I get an extra line break in the REPL when evaluating lines other than the first line of the buffer. https://github.com/jorgenschaefer/elpy/issues/924#issuecomment-314922197 > This is not an elpy issue, it also occurs with plain python-mode. It > seems to be caused by certain versions of Python only. A quick-and-dirty > fix is (in .emacs): > > (defun python-shell-append-to-output (string) > (let ((buffer (current-buffer))) > (set-buffer (process-buffer (python-shell-get-process))) > (let ((oldpoint (point))) > (goto-char (process-mark (python-shell-get-process))) > (insert string) > (set-marker (process-mark (python-shell-get-process)) (point)) > (goto-char oldpoint)) > (set-buffer buffer))) > > (defadvice python-shell-send-string > (around advice-python-shell-send-string activate) > (interactive) > (let* ((append-string1 > (if (string-match "import codecs, os;__pyfile = codecs.open.*$" string) > (replace-match "" nil nil string) > string)) > (append-string2 > (if (string-match "^# -\\*- coding: utf-8 -\\*-\n*$" append-string1) > (replace-match "" nil nil append-string1) > append-string1)) > (append-string > (if (string-match "^\n*$" append-string2) > (replace-match "" nil nil append-string2) > append-string2))) > (python-shell-append-to-output > (concat (string-trim-right append-string) "\n"))) > (if (called-interactively-p 'any) > (call-interactively (ad-get-orig-definition 'python-shell-send-string)) > ad-do-it))