From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#50057: 27.2; Issue evaluating Python code across machines Date: Sat, 14 Aug 2021 18:01:28 +0200 Message-ID: <8735rcc8x3.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22455"; mail-complaints-to="usenet@ciao.gmane.io" To: 50057@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 14 18:02:44 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 1mEw7Q-0005i4-29 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Aug 2021 18:02:44 +0200 Original-Received: from localhost ([::1]:57048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEw7O-0002YU-Rp for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Aug 2021 12:02:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEw6l-00015x-Dd for bug-gnu-emacs@gnu.org; Sat, 14 Aug 2021 12:02:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEw6k-0006lk-DW for bug-gnu-emacs@gnu.org; Sat, 14 Aug 2021 12:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mEw6k-0005KQ-6p for bug-gnu-emacs@gnu.org; Sat, 14 Aug 2021 12:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Aug 2021 16:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50057 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162895690020452 (code B ref -1); Sat, 14 Aug 2021 16:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Aug 2021 16:01:40 +0000 Original-Received: from localhost ([127.0.0.1]:45296 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEw6O-0005Jo-5b for submit@debbugs.gnu.org; Sat, 14 Aug 2021 12:01:40 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:40822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEw6K-0005Jf-UC for submit@debbugs.gnu.org; Sat, 14 Aug 2021 12:01:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEw6J-0008UF-VA for bug-gnu-emacs@gnu.org; Sat, 14 Aug 2021 12:01:36 -0400 Original-Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:42768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEw6I-0006R2-5D for bug-gnu-emacs@gnu.org; Sat, 14 Aug 2021 12:01:35 -0400 Original-Received: by mail-wr1-x42a.google.com with SMTP id q11so17432498wrr.9 for ; Sat, 14 Aug 2021 09:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=I29RTPwpn9vbyia3di+j2Hxjf+kG2AHbZbX35VRQRE4=; b=mlSitQiMhaY/wC7KRSv93CZxnrpxvjdpDiaoZIP5tkw1MrAovcv52jRFS+TkBtbDKs aejPJVO6mrOYerPnrx1KbIiev1MURLRopf9EvunV5MqMtvsqWHo+ATz86uytKkYwFdfU XdMpeozQBpvsD5uxv3MpAr8na/4u7suqddO6UgxspkXQFXzPX9wN9++jS+iyoflb7nCE qZXrC/K4mS27HNi8RBzkiu6BIHdQ7J558FteQ1eu38bYNYv/ES3FmnksqijluDM5DJT8 qI3ZJueDEK79WXesAS7fTR6N1mk1sBsGFfIdTvW0R2Bh9EMbvK8JfnBvV5WeujHALDLd A+ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=I29RTPwpn9vbyia3di+j2Hxjf+kG2AHbZbX35VRQRE4=; b=ps0Pp4YfmoQ/6EbXa+jMebdCN5myOKqNqGzs3lhpppNX5gkeyA3DEMXTsuC6DHDksR nVOqHyVuZVE9u5xOWo5eqMq9n2P8/CjL7mP33819T3/Mx5Ws703pB5LJXzMEZRrKZmE8 DiM4/ZQowC+CenTXFukEhT1ThqG3EnJpX5lFWwmSmOBiIOzMMWI8tJtcUXwLpNTvSc/9 fM19ZrpmQCbVsdyX1i9jj6MLVNUQXBt80Wb7c7sw6pRK0UWgJjZ7B4HTTZ5AwhszszKb ZIwbkz9tt73RdWI3GWGvvfKTbJcOj3BX0/LFbloQoaWRCp9eTBy7/eRaFzKs1grwqJJ7 00jw== X-Gm-Message-State: AOAM5335LkoU1sTQ81Lx9t0/dIfvjpo51XePWdFHuM8P1fo+9AWYQSok Ii7lWgP2EEf64zgaXuvuoyian4oTE0Y= X-Google-Smtp-Source: ABdhPJwYPYc5X/zsbDELRBnPA32AGas7WqhOXrfKMut5atnW0pkAD9e5j7fVBC8B9JK94Av+bLer3Q== X-Received: by 2002:adf:e887:: with SMTP id d7mr8720541wrm.79.1628956890629; Sat, 14 Aug 2021 09:01:30 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::ae3f]) by smtp.gmail.com with ESMTPSA id i14sm4510848wmq.40.2021.08.14.09.01.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Aug 2021 09:01:30 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=arstoffel@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:211844 Archived-At: --=-=-= Content-Type: text/plain Suppose the current buffer is editing a local file and you would like to evaluate some code on a Python inferior running in a remote machine. The following should work: (let ((default-directory "/ssh:some-remote-machine:/")) (run-python)) (python-shell-send-string "5+5") (python-shell-send-string "(5\n+5)") The first python-shell-send-string call indeed works. The second one produces an error, because a temporary file is created in the local machine instead of the remote one. The same kind of error happens if one tries to evaluate the region on the entire buffer. I've attached a small patch to fix this. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Allow-evaluating-Python-code-across-machines.patch >From b3f47f99da7b8ac2221b6bbafc85ae8076f92703 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Sat, 14 Aug 2021 17:48:45 +0200 Subject: [PATCH] Allow evaluating Python code across machines * python.el (python-shell-send-string): Ensure that the temporary file is created in the host running the Python process. --- lisp/progmodes/python.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 2557704e40..20299c20d2 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3085,7 +3085,8 @@ python-shell-send-string (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)) + (let* ((temp-file-name (with-current-buffer (process-buffer process) + (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)) (comint-send-string process string) -- 2.31.1 --=-=-=--