From unknown Thu Aug 14 21:52:54 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#58389 <58389@debbugs.gnu.org> To: bug#58389 <58389@debbugs.gnu.org> Subject: Status: 29.0.50; Python completion fails under certain conditions Reply-To: bug#58389 <58389@debbugs.gnu.org> Date: Fri, 15 Aug 2025 04:52:54 +0000 retitle 58389 29.0.50; Python completion fails under certain conditions reassign 58389 emacs submitter 58389 kobarity severity 58389 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 09 02:58:47 2022 Received: (at submit) by debbugs.gnu.org; 9 Oct 2022 06:58:47 +0000 Received: from localhost ([127.0.0.1]:41844 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohQGs-0000m5-Qt for submit@debbugs.gnu.org; Sun, 09 Oct 2022 02:58:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:56046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohQGr-0000lw-0o for submit@debbugs.gnu.org; Sun, 09 Oct 2022 02:58:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohQGq-0001YY-OR for bug-gnu-emacs@gnu.org; Sun, 09 Oct 2022 02:58:44 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:37707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohQGn-0007nq-NP for bug-gnu-emacs@gnu.org; Sun, 09 Oct 2022 02:58:44 -0400 Received: by mail-pg1-x533.google.com with SMTP id bh13so7990829pgb.4 for ; Sat, 08 Oct 2022 23:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:subject:to:from:message-id:date:from:to:cc :subject:date:message-id:reply-to; bh=10WIWXbitJ3pnd/GQc6/E0abf4+j82lmAVrkYVHVabk=; b=j26QhC9Cn6lE4KS0MoENuQUXoJkkjLIEIVEyemkdnR7V3tHzfsH2WdxiMCqqksFwQW y9WamcAo4wirXu0xoXoYNc0voiUX/xDmuBptrSLsG2NSzDHRQTE8Zd9g0JXwcR1KjP5k u6FKHU2TOjvjAvXe1RyYpSPBYoHQm3qeJAqjBFKveNMoR2U3dP2bLJenF5E/HJEcUMZa bYATP60VlaRj8H3BOD8KYpreAGgY4R+ggbexVqRCakVTQIUk4jTUgwLyUhKpf8BtswA8 yCTYKXjn8sHcl6Q6QYZ4qJQQ9Kr3F7UXIYNgdBNeHv/H47d0fGoFPo4HLbn0UOYjqG14 8PaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:subject:to:from:message-id:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=10WIWXbitJ3pnd/GQc6/E0abf4+j82lmAVrkYVHVabk=; b=jRHQrKQyGYUJlBbGjQVYfLl5GMDt17WjtePk0DO0b9jr2xqCVIKazkwws1JPunIVwv ZjKaINuGxWOoZrD7Wj4XdGXYisdtVizWHwwJeXEaqY9hRnCYTSBCbMVEI4JYmJLoPP4j r6ey7+yKmjl34uuOG8DcOkAVbBo/RAL1u/MqqQ95OQwI8evsd8TuIuNJLrd4FJRmjHIb QoOsLVEf/R6kyVfSRBBN/DcSI1vxDt+RIoDGFG58Nr2y2E9V4TfbWtPC2/88v4Q8nz2A XeAyicxGvaBk0umgXeNuQTZNglYnrhZoHrwhJR8CBtAEP32gK4u+/XVak3nX7jigP9ys 0xGg== X-Gm-Message-State: ACrzQf1eRIM/LmgK08K1Yxry1FC6RHx3QKgr4qEn04SEg6icYCAO9zy4 pFNh/93J8r5aWId7ZgQqd+C5whUF+kI= X-Google-Smtp-Source: AMsMyM4Zev/DarsXa5gjpcvCyfZT2OTZhPW1dWSc38sCmBziv70uNQZ7fPvJvAKJ+Th2gExbxsvgOA== X-Received: by 2002:a05:6a00:1a07:b0:541:6060:705d with SMTP id g7-20020a056a001a0700b005416060705dmr13881501pfv.61.1665298719099; Sat, 08 Oct 2022 23:58:39 -0700 (PDT) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id b8-20020a170903228800b0016c9e5f291bsm4340227plh.111.2022.10.08.23.58.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Oct 2022 23:58:38 -0700 (PDT) Date: Sun, 09 Oct 2022 15:58:11 +0900 Message-ID: From: kobarity To: bug-gnu-emacs@gnu.org Subject: 29.0.50; Python completion fails under certain conditions User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: multipart/mixed; boundary="Multipart_Sun_Oct__9_15:58:10_2022-1" Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=kobarity@gmail.com; helo=mail-pg1-x533.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-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --Multipart_Sun_Oct__9_15:58:10_2022-1 Content-Type: text/plain; charset=US-ASCII Hi, Completion in Python mode buffer fails under certain conditions: - non-native completion is used, - ElDoc mode is used, or - FFAP is used. Here is how to reproduce the problem of non-native completion: 1. emacs -Q 2. Open the following Python file. #+begin_src python import sys #+end_src 3. Use M-x customize-variable to disable python-shell-completion-native-enable 4. C-u -1 M-x eldoc-mode (Disable ElDoc mode) 5. C-c C-p (M-x run-python) 6. C-x o (Back to the Python mode buffer) 7. C-c C-c (M-x python-shell-send-buffer) 8. C-n (M-x next-line) 9. Type "sys." 10. C-M-i (M-x completion-at-point) 11. Completions are shown in *Completions* buffer. 12. Type "e" 13. C-M-i (M-x completion-at-point) 14. "No match" is shown in the minibuffer. This does not happen when native completion is enabled and ElDoc mode is disabled. The following steps show the problem of ElDoc mode: 1. emacs -Q 2. Open the following Python file. #+begin_src python import sys #+end_src 3. Make sure that ElDoc mode is enabled. 4. C-c C-p (M-x run-python) 5. Make sure that "Shell native completion is enabled." is shown in the minibuffer. 6. C-x o (Back to the Python mode buffer) 7. C-c C-c (M-x python-shell-send-buffer) 8. C-n (M-x next-line) 9. Type "sys." 10. Wait for 1-2 seconds to make sure ElDoc function is run by the idle timer. 11. C-M-i (M-x completion-at-point) 12. "No match" is shown in the minibuffer. The problem with FFAP can be reproduced with similar steps. The direct cause of these problems is that `python-util-comint-last-prompt' returns nil, which is not supposed in `python-shell-completion-at-point'. `python-util-comint-last-prompt' is a wrapper to return `comint-last-prompt'. `comint-last-prompt' is initialized to nil in `comint-snapshot-last-prompt' and is set in `comint-output-filter'. However, `python-shell-send-string-no-output' which is used by the features mentioned above temporarily changes the `process-filter' to redirect the output. This causes `comint-output-filter' to not be called and `comint-last-prompt' to remain nil. I think `comint-snapshot-last-prompt' should not be called as long as `comint-output-filter' is not called and the Inferior Python Shell buffer is not changed. Attached is a patch to fix this issue. Best Regards, -- In GNU Emacs 29.0.50 (build 5, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2022-10-09 built on ubuntu Repository revision: 9d47364634f96b2f2651a7f3942f8f87b920f02d Repository branch: master System Description: Ubuntu 22.04.1 LTS Configured using: 'configure --without-libgmp' Configured features: ACL CAIRO FREETYPE GIF GLIB GNUTLS GSETTINGS HARFBUZZ JPEG LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils term/screen term/xterm xterm byte-opt gv bytecomp byte-compile cconv rmc iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads inotify dynamic-setting system-font-setting font-render-setting cairo x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 46148 9345) (symbols 48 5790 0) (strings 32 15049 1660) (string-bytes 1 427012) (vectors 16 8356) (vector-slots 8 105418 10463) (floats 8 24 349) (intervals 56 216 0) (buffers 1000 11)) --Multipart_Sun_Oct__9_15:58:10_2022-1 Content-Type: application/octet-stream; type=patch; name="0001-Fix-Python-completion-failure-under-certain-conditio.patch" Content-Disposition: attachment; filename="0001-Fix-Python-completion-failure-under-certain-conditio.patch" Content-Transfer-Encoding: 7bit >From 6bd4d7fdf16cda18a921c2b63221fc2aac84fb8c Mon Sep 17 00:00:00 2001 From: kobarity Date: Sun, 9 Oct 2022 15:39:52 +0900 Subject: [PATCH] Fix Python completion failure under certain conditions * lisp/progmodes/python.el (python-shell-send-string-no-output): Invalidate `comint-snapshot-last-prompt'. * test/lisp/progmodes/python-tests.el (python-tests-shell-wait-for-prompt): New helper function. (python-tests-with-temp-buffer-with-shell): New helper macro. (python-shell-completion-1, python-shell-completion-native-1) (python-shell-completion-native-with-ffap-1) (python-shell-completion-native-with-eldoc-1): New tests. --- lisp/progmodes/python.el | 2 + test/lisp/progmodes/python-tests.el | 90 +++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 80c5b31b6e..9f29eb417e 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3417,6 +3417,8 @@ python-shell-send-string-no-output (lambda (_proc str) (with-current-buffer (process-buffer process) (python-shell-output-filter str)))) + ((symbol-function 'comint-snapshot-last-prompt) + #'ignore) (python-shell-output-filter-in-progress t) (inhibit-quit t)) (or diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index fdaedb5fd7..eed9c18ede 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -43,6 +43,34 @@ python-tests-with-temp-buffer (goto-char (point-min)) ,@body))) +(defun python-tests-shell-wait-for-prompt () + "Wait for the prompt in the shell buffer." + (with-current-buffer (python-shell-get-buffer) + (while (not (python-util-comint-last-prompt)) + (sit-for 0.1)))) + +(defmacro python-tests-with-temp-buffer-with-shell (contents &rest body) + "Create a `python-mode' enabled temp buffer with CONTENTS and `run-python'. +BODY is code to be executed within the temp buffer. Point is +always located at the beginning of buffer. Native completion is +turned off. Shell buffer will be killed on exit." + (declare (indent 1) (debug t)) + `(with-temp-buffer + (let ((python-indent-guess-indent-offset nil) + (python-shell-completion-native-enable nil)) + (python-mode) + (unwind-protect + (progn + (run-python nil t) + (insert ,contents) + (goto-char (point-min)) + (python-tests-shell-wait-for-prompt) + ,@body) + (when (python-shell-get-buffer) + (python-shell-with-shell-buffer + (let (kill-buffer-hook kill-buffer-query-functions) + (kill-buffer)))))))) + (defmacro python-tests-with-temp-file (contents &rest body) "Create a `python-mode' enabled file with CONTENTS. BODY is code to be executed within the temp buffer. Point is @@ -4365,6 +4393,68 @@ python-shell-completion-native-interpreter-disabled-p-1 (python-shell-interpreter "/some/path/to/bin/pypy")) (should (python-shell-completion-native-interpreter-disabled-p)))) +(ert-deftest python-shell-completion-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "abc.") + (should (completion-at-point)) + (insert "A") + (should (completion-at-point))))) + +(ert-deftest python-shell-completion-native-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-completion-native-turn-on) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "abc.") + (should (completion-at-point)) + (insert "A") + (should (completion-at-point))))) + +(ert-deftest python-shell-completion-native-with-ffap-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-completion-native-turn-on) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "abc.") + ;; This is called when FFAP is enabled and a find-file function is called. + (python-ffap-module-path "abc.") + (should (completion-at-point))))) + +(ert-deftest python-shell-completion-native-with-eldoc-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-completion-native-turn-on) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "abc.") + ;; This is called by idle-timer when ElDoc is enabled. + (python-eldoc-function) + (should (completion-at-point))))) -- 2.34.1 --Multipart_Sun_Oct__9_15:58:10_2022-1-- From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 09 07:23:59 2022 Received: (at 58389) by debbugs.gnu.org; 9 Oct 2022 11:23:59 +0000 Received: from localhost ([127.0.0.1]:42235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohUPX-0007iH-Cr for submit@debbugs.gnu.org; Sun, 09 Oct 2022 07:23:59 -0400 Received: from mail-pg1-f182.google.com ([209.85.215.182]:37863) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohUPV-0007i4-RE for 58389@debbugs.gnu.org; Sun, 09 Oct 2022 07:23:58 -0400 Received: by mail-pg1-f182.google.com with SMTP id bh13so8248484pgb.4 for <58389@debbugs.gnu.org>; Sun, 09 Oct 2022 04:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:references:in-reply-to:subject:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=hwak3n0EWHDlewJttqW/3apHfHFRmL6IEVAZslWPx9Y=; b=WL61C6zKsV3FTfpYRo8w/N6TKByFUT+Ne89d4NacMg2YkNehqruRikajBuM8zdqp3I gjC8XFFZ4kWzLcwtNVu2q5voqWyLEeGdQ+bNJny82hJq36SLbYMF3BZoBp8A3hYFEwPe p/YX3stpH6m2E6Bvmb3RttFlx94h8KBjXOuT/aF5y2FXRrCo3saNlqRc/nuqnzJZtQqW DCaylYLIZYDSb16FfE2H/uEPp9froTuh6f/DN9A0ZLe/GLrTGse2iAUYnVcYLezQO4lu zK4h3juTuIpo3czONhnomLTLSq2JfIXmuVudIyjLVOJ1lXv6+Q+RzTT6tZn4+STYBKDd p08A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:references:in-reply-to:subject:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hwak3n0EWHDlewJttqW/3apHfHFRmL6IEVAZslWPx9Y=; b=0X91+XZz96PEV9iuxFOgp17HSonjB2HCaT8uxRzZq0voNiCmxBn6G5EiMRdfc56Sd8 6b940BiH+6mCNdZRiPGu4DvraHFm+v3cltwd7LUU1dieBxvj6W0FPm1crNxDhFPjAILU wy7u41ExovSftlc74BF+bjVnP1In/GzO6rnil4C0zOXrGFE/4ngblgcopcL7bt/e3Uri fPzJympnbdLP5Vq1gTuSy4jfpn/cmI93h96GzBD04ghvtUNyWIuTAkBkhRqDbVlzULno yZfhURN0FuO50+e8hgPaN30A02pK3hRvjFojPis/kJWnNcXJTUS3+nMZ9U3EwmAzflRs G7lA== X-Gm-Message-State: ACrzQf1EDW66qcdE0LIqsLJfWkHKs/KLYPDJ1UHWj0c3lv7f2icwiIKD TQntV+50DLQOobMJkSQ0FdLUeV7jHOs= X-Google-Smtp-Source: AMsMyM45hrRpVGqpJfSrZndPSlL21joq2ZofNvVCJSqZkHgOBJjw+hrJ/ScY0RjqHIBPetBzeRZHhQ== X-Received: by 2002:a63:1508:0:b0:438:eb90:52d1 with SMTP id v8-20020a631508000000b00438eb9052d1mr12487487pgl.252.1665314631530; Sun, 09 Oct 2022 04:23:51 -0700 (PDT) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id n32-20020a634d60000000b0044e8d66ae05sm4438034pgl.22.2022.10.09.04.23.49 for <58389@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Oct 2022 04:23:50 -0700 (PDT) Date: Sun, 09 Oct 2022 20:23:47 +0900 Message-ID: From: kobarity To: 58389@debbugs.gnu.org Subject: Re: 29.0.50; Python completion fails under certain conditions In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58389 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) I wrote: > I think `comint-snapshot-last-prompt' should not be called as long as > `comint-output-filter' is not called and the Inferior Python Shell > buffer is not changed. Attached is a patch to fix this issue. Sorry, I was not aware of other processes using comint. It might affect other processes. I will reconsider the patch. Best Regards, From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 10 09:29:31 2022 Received: (at 58389) by debbugs.gnu.org; 10 Oct 2022 13:29:31 +0000 Received: from localhost ([127.0.0.1]:46412 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohsqY-0004I0-JM for submit@debbugs.gnu.org; Mon, 10 Oct 2022 09:29:30 -0400 Received: from mail-pl1-f181.google.com ([209.85.214.181]:35438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohsqW-0004Ho-VK for 58389@debbugs.gnu.org; Mon, 10 Oct 2022 09:29:29 -0400 Received: by mail-pl1-f181.google.com with SMTP id h10so10397888plb.2 for <58389@debbugs.gnu.org>; Mon, 10 Oct 2022 06:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:references:in-reply-to:subject:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=+hGtgH9dzijk2iyhsubrnNOWupjoUTpT4TtT0fe9H94=; b=msU530MoiS9+n14KNnTl0GrvrtQf9DgWRTjRYeDAerm+J+zXoTfll88ip7pLobdDBc tccsvLeQX3kPQfkNeRi9rmDTqgEoGFP5XycTEZGpOcimP+B/w3CZyI4yT/iwBSElV/R0 Jrscx6g3KMUqSymdLc6eNzFfAZYsXt5uAlAtzQh5H2FFxncRdxAvCcWH4ehTUgcyGMON sTkuxtLE//5R1ZjGomt2vyNh3vDEhX/g4mtrzvj1K66T1qLqPcWxEtFxfkDABdS5A2mp IY88fARShEG3WfCqzi3wwS+UnhT7ZDrzVdRrzWiGbjATky1+CbQHYeLWfaLQI3RWQTx7 b49g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:references:in-reply-to:subject:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+hGtgH9dzijk2iyhsubrnNOWupjoUTpT4TtT0fe9H94=; b=zg3pR7rLSaHxwpsHSZj6J38GsUfekLGoW2BgoPxnNblEwFHGpa5HVfBrDak3ESsxoA aw5BajV9hlnzySpXI1cyboWaulhA0vHCIv4hKwiFkBRbLa5lKBLb8QTUCZZsGXTLuHLu UeH1fxFqp4akXQ/rACzQ9DdQwFiN4aj4HtMiZpQTv+nWOAR3iH2e2C/U7qsTaZvsAev3 S+80wG09VvBHx8tsjvYVMKKNETU4LAN7YbJnR4INEsi8RvZ3nuz03hr9IRqZz6w3DcnY 1w6XGU3dVMYANQuMpSOR0LKIDGDnZbclPJj5+eVjB728CCWrHryZPpgHhYnsQsBymV2d jZXg== X-Gm-Message-State: ACrzQf0Vo6wUn2DEJnaFgZZJ/M6MTn5RYhjx3pfZwitFKimscbU041+C a2eEQuaiHQUuTwea8HiGXyJnqidyh8o= X-Google-Smtp-Source: AMsMyM6S6BUiVq9hJ/kQMjVGkj5XM8cqM+2dxaEhMERWYoXuD0Fz9F/Z00ksgkWgRoWvqmisYRUfAA== X-Received: by 2002:a17:90b:1a81:b0:20a:71e5:728d with SMTP id ng1-20020a17090b1a8100b0020a71e5728dmr31101813pjb.107.1665408561343; Mon, 10 Oct 2022 06:29:21 -0700 (PDT) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id e7-20020a170902784700b00176ca74c58bsm4584044pln.245.2022.10.10.06.29.19 for <58389@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 06:29:20 -0700 (PDT) Date: Mon, 10 Oct 2022 22:29:16 +0900 Message-ID: From: kobarity To: 58389@debbugs.gnu.org Subject: Re: 29.0.50; Python completion fails under certain conditions In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: multipart/mixed; boundary="Multipart_Mon_Oct_10_22:29:15_2022-1" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58389 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Multipart_Mon_Oct_10_22:29:15_2022-1 Content-Type: text/plain; charset=US-ASCII I wrote: > > I wrote: > > I think `comint-snapshot-last-prompt' should not be called as long as > > `comint-output-filter' is not called and the Inferior Python Shell > > buffer is not changed. Attached is a patch to fix this issue. > > Sorry, I was not aware of other processes using comint. It might > affect other processes. I will reconsider the patch. Attached is the revised patch to fix this issue. Instead of invalidating `comint-snapshot-last-prompt', I added codes to save and restore the buffer local variable `comint-last-prompt-overlay' or `comint-last-prompt'. Best Regards, --Multipart_Mon_Oct_10_22:29:15_2022-1 Content-Type: application/octet-stream; type=patch; name="0001-Fix-Python-completion-failure-under-certain-conditio.patch" Content-Disposition: attachment; filename="0001-Fix-Python-completion-failure-under-certain-conditio.patch" Content-Transfer-Encoding: 7bit >From 5962306d13d77aac25e0d991e8aaaab34d499c86 Mon Sep 17 00:00:00 2001 From: kobarity Date: Mon, 10 Oct 2022 22:24:17 +0900 Subject: [PATCH] Fix Python completion failure under certain conditions * lisp/progmodes/python.el (python-shell-send-string-no-output): Save and restore `comint-last-prompt-overlay' or `comint-last-prompt'. * test/lisp/progmodes/python-tests.el (python-tests-shell-wait-for-prompt): New helper function. (python-tests-with-temp-buffer-with-shell): New helper macro. (python-shell-completion-1, python-shell-completion-native-1) (python-shell-completion-native-with-ffap-1) (python-shell-completion-native-with-eldoc-1): New tests (bug#58389). --- lisp/progmodes/python.el | 26 +++++--- test/lisp/progmodes/python-tests.el | 93 +++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 80c5b31b6e..680b57fc3e 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3413,15 +3413,25 @@ python-shell-send-string-no-output "Send STRING to PROCESS and inhibit output. Return the output." (or process (setq process (python-shell-get-process-or-error))) - (cl-letf (((process-filter process) - (lambda (_proc str) - (with-current-buffer (process-buffer process) - (python-shell-output-filter str)))) - (python-shell-output-filter-in-progress t) - (inhibit-quit t)) + (cl-letf* (((process-filter process) + (lambda (_proc str) + (with-current-buffer (process-buffer process) + (python-shell-output-filter str)))) + (python-shell-output-filter-in-progress t) + (inhibit-quit t) + (buffer (process-buffer process)) + (last-prompt (cond ((boundp 'comint-last-prompt-overlay) + 'comint-last-prompt-overlay) + ((boundp 'comint-last-prompt) + 'comint-last-prompt))) + (last-prompt-value (buffer-local-value last-prompt buffer))) (or (with-local-quit - (python-shell-send-string string process) + (unwind-protect + (python-shell-send-string string process) + (when (not (null last-prompt)) + (with-current-buffer buffer + (set last-prompt last-prompt-value)))) (while python-shell-output-filter-in-progress ;; `python-shell-output-filter' takes care of setting ;; `python-shell-output-filter-in-progress' to NIL after it @@ -3430,7 +3440,7 @@ python-shell-send-string-no-output (prog1 python-shell-output-filter-buffer (setq python-shell-output-filter-buffer nil))) - (with-current-buffer (process-buffer process) + (with-current-buffer buffer (comint-interrupt-subjob))))) (defun python-shell-internal-send-string (string) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index fdaedb5fd7..60ff9bb613 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -43,6 +43,37 @@ python-tests-with-temp-buffer (goto-char (point-min)) ,@body))) +(defun python-tests-shell-wait-for-prompt () + "Wait for the prompt in the shell buffer." + (python-shell-with-shell-buffer + (while (not (if-let ((prompt (python-util-comint-last-prompt))) + (python-shell-comint-end-of-output-p + (buffer-substring-no-properties + (car prompt) (cdr prompt))))) + (sit-for 0.1)))) + +(defmacro python-tests-with-temp-buffer-with-shell (contents &rest body) + "Create a `python-mode' enabled temp buffer with CONTENTS and `run-python'. +BODY is code to be executed within the temp buffer. Point is +always located at the beginning of buffer. Native completion is +turned off. Shell buffer will be killed on exit." + (declare (indent 1) (debug t)) + `(with-temp-buffer + (let ((python-indent-guess-indent-offset nil) + (python-shell-completion-native-enable nil)) + (python-mode) + (unwind-protect + (progn + (run-python nil t) + (insert ,contents) + (goto-char (point-min)) + (python-tests-shell-wait-for-prompt) + ,@body) + (when (python-shell-get-buffer) + (python-shell-with-shell-buffer + (let (kill-buffer-hook kill-buffer-query-functions) + (kill-buffer)))))))) + (defmacro python-tests-with-temp-file (contents &rest body) "Create a `python-mode' enabled file with CONTENTS. BODY is code to be executed within the temp buffer. Point is @@ -4365,6 +4396,68 @@ python-shell-completion-native-interpreter-disabled-p-1 (python-shell-interpreter "/some/path/to/bin/pypy")) (should (python-shell-completion-native-interpreter-disabled-p)))) +(ert-deftest python-shell-completion-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "abc.") + (should (completion-at-point)) + (insert "A") + (should (completion-at-point))))) + +(ert-deftest python-shell-completion-native-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-completion-native-turn-on) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "abc.") + (should (completion-at-point)) + (insert "A") + (should (completion-at-point))))) + +(ert-deftest python-shell-completion-native-with-ffap-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-completion-native-turn-on) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "abc.") + ;; This is called when FFAP is enabled and a find-file function is called. + (python-ffap-module-path "abc.") + (should (completion-at-point))))) + +(ert-deftest python-shell-completion-native-with-eldoc-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import abc +" + (let ((inhibit-message t)) + (python-shell-completion-native-turn-on) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "abc.") + ;; This is called by idle-timer when ElDoc is enabled. + (python-eldoc-function) + (should (completion-at-point))))) -- 2.34.1 --Multipart_Mon_Oct_10_22:29:15_2022-1-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 10 20:30:10 2022 Received: (at 58389) by debbugs.gnu.org; 11 Oct 2022 00:30:10 +0000 Received: from localhost ([127.0.0.1]:50285 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oi39t-0005Jd-Rm for submit@debbugs.gnu.org; Mon, 10 Oct 2022 20:30:10 -0400 Received: from quimby.gnus.org ([95.216.78.240]:60464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oi39t-0005IK-1n for 58389@debbugs.gnu.org; Mon, 10 Oct 2022 20:30:09 -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:Date:References: In-Reply-To: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=0dQQUxqklb6Aj5mwWqOVPhZt8wofCAM0UYyaWyvzI2g=; b=NqNXoSDilF92VHwM9HOmXpPrbT zyc0d4EBx1bvpR8R2spsiw0X0XlU+NYB/B1vhRk8dGbxK7js4eZdKbJNQ0em6z1p4wOBBH5pRpOyj /Hg/q2zdxuFCDvUprh1881qPBKecjo4vqk9sPrXbIOxvDSLE5dk0ERwH1P0iRbA1WWXU=; Received: from [84.212.220.105] (helo=downe) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oi39k-0006CS-1x; Tue, 11 Oct 2022 02:30:03 +0200 From: Lars Ingebrigtsen To: kobarity Subject: Re: bug#58389: 29.0.50; Python completion fails under certain conditions In-Reply-To: (kobarity@gmail.com's message of "Mon, 10 Oct 2022 22:29:16 +0900") References: X-Now-Playing: Adam F's _15 Years of Metalheadz_: "Metropolis" Date: Tue, 11 Oct 2022 02:29:59 +0200 Message-ID: <875ygrkxrs.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: kobarity writes: > Attached is the revised patch to fix this issue. Instead of > invalidating `comint-snapshot-last-prompt', I added codes to save and > restore the buffer local variable `comint-last-prompt-overlay' o [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58389 Cc: 58389@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) kobarity writes: > Attached is the revised patch to fix this issue. Instead of > invalidating `comint-snapshot-last-prompt', I added codes to save and > restore the buffer local variable `comint-last-prompt-overlay' or > `comint-last-prompt'. Thanks; pushed to Emacs 29. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 10 20:30:17 2022 Received: (at control) by debbugs.gnu.org; 11 Oct 2022 00:30:17 +0000 Received: from localhost ([127.0.0.1]:50288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oi3A1-0005K1-56 for submit@debbugs.gnu.org; Mon, 10 Oct 2022 20:30:17 -0400 Received: from quimby.gnus.org ([95.216.78.240]:60478) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oi39z-0005Jn-Vg for control@debbugs.gnu.org; Mon, 10 Oct 2022 20:30:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=eopiv7RAmB2LlgF5u7jIKSoKRu/tQtunTgy1zYHbZN0=; b=bJvRS2Tc+nlLdtwXTo2Pm2z14j 2OmL7SiiV5k3k8WwAh5QHOPIRrLS6gZLwY5StYOgZTimj0BmJRt7uQOPkTYDEoo2/Iam4Ksu0+uDX ZIpsgXi02aM9NNipO1aCT7MdBTeT6UDpO6J5AtSmC2arPZP+c4ao85xAQiIGGsRvPOu0=; Received: from [84.212.220.105] (helo=downe) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oi39q-0006Ci-Qy for control@debbugs.gnu.org; Tue, 11 Oct 2022 02:30:09 +0200 Date: Tue, 11 Oct 2022 02:30:06 +0200 Message-Id: <874jwbkxrl.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #58389 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 58389 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 58389 29.1 quit From unknown Thu Aug 14 21:52:54 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 08 Nov 2022 12:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator