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#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point) Date: Tue, 07 May 2024 00:12:10 +0900 Message-ID: References: Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10914"; 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: 70707@debbugs.gnu.org To: Lin Sun Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 06 17:12:58 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 1s401S-0002cJ-09 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 May 2024 17:12:58 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4019-0005N4-VN; Mon, 06 May 2024 11:12:39 -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 1s4018-0005Ly-LA for bug-gnu-emacs@gnu.org; Mon, 06 May 2024 11:12:38 -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 1s4018-0006k1-Ah for bug-gnu-emacs@gnu.org; Mon, 06 May 2024 11:12:38 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s401W-0005rA-FX for bug-gnu-emacs@gnu.org; Mon, 06 May 2024 11:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 May 2024 15:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70707 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70707-submit@debbugs.gnu.org id=B70707.171500837222501 (code B ref 70707); Mon, 06 May 2024 15:13:02 +0000 Original-Received: (at 70707) by debbugs.gnu.org; 6 May 2024 15:12:52 +0000 Original-Received: from localhost ([127.0.0.1]:38579 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s401M-0005qr-89 for submit@debbugs.gnu.org; Mon, 06 May 2024 11:12:52 -0400 Original-Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:58638) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s401J-0005qd-6O for 70707@debbugs.gnu.org; Mon, 06 May 2024 11:12:50 -0400 Original-Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1eb24e3a2d9so19836895ad.1 for <70707@debbugs.gnu.org>; Mon, 06 May 2024 08:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715008339; x=1715613139; 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=niY0ES2RPn1B6WnxjLkNmPqUET8cPp6a+q4bo8i7fnQ=; b=Whe4ckIft8i+q2Z2D1x5aZPmVLlIyQBFeduIeH0uXgrI/OdsEWE8PFjFJ8dJnM+8GB qI/sYPA64ziZ0IfbxNBbDyCDNxveWKwncpjB0Io8GiBiyuvLWoXgQefkltVyyI+HYDoV diiBR6NfuLjDhR2MuaIibks4EuYoSSRJWbpKInYCgtCAj4qBGuhyRWmblaylYZ2v4lpv LXd9Jg+roPqzQvvNHrRsZLnHWpAquylVHguTaB/ZnIQHstIUpvWVy2vWlS0Ul+uo2xX3 bGrFliEE8Ag/gJ8MIHJiN5Kn1DM2/9SaG6HZGX51t4A9fAA3LkoFYbtJkbkcWLs4tPRM XAiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715008339; x=1715613139; 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=niY0ES2RPn1B6WnxjLkNmPqUET8cPp6a+q4bo8i7fnQ=; b=Q28pkCOMH6AE4Gbwte7EmD7T0mPYYriv9GTUktVU4NmiAEWIyUt/JqrYEucJkWqulf zjMinJ6z4uk3EMxOSR/wq4A4PUnMQZHfJEtIRLPfh6N/Tg/0fXgwNqLCPjgIG271U27R BW472I1ZSc+2egFMzRfllcvF5S2zfXrvz/9ZqYK4g/bpdkQ67C3p79uvq39ZR6VK2Nng jSJrTsdGjCMDZ7Jorp7r6NZdovNuD++hicpF+X02SKecKpYd62PwIb1NnahT11COvdYQ T23dHzBNTldzsSqXl1YPYIQAPWJR6Zc4lRxVQXutaGV7hqh9RN09qAirSRGYg4Rr5uO8 4ZXw== X-Gm-Message-State: AOJu0YygL/hc5PqVg4zZO3Ue4nRfIihJAnSl/uT//Kw5Jxh0We4520Gw 1isO7FeI5bfZpknHUb91ncRZX9WhkpgD0iLCzMaAWh9gme65ROyO X-Google-Smtp-Source: AGHT+IGi9vXHjrVBTzRn8KfXuk7ksCbbpvSibUl9OfuYrukj6dfht96t3UKAsrqOb5F4VBwgf2dvcg== X-Received: by 2002:a17:902:b186:b0:1e2:9066:4a8b with SMTP id s6-20020a170902b18600b001e290664a8bmr12437073plr.26.1715008338659; Mon, 06 May 2024 08:12:18 -0700 (PDT) Original-Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id h13-20020a170902680d00b001e2a4663179sm2776330plk.258.2024.05.06.08.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 08:12:18 -0700 (PDT) In-Reply-To: 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:284583 Archived-At: Lin Sun wrote: > > > Hi, > > > > There is an unexpected error message happening with function > > `python-shell-completion-at-point`. > > > Wrong type argument: processp, nil > > It happened because the function does NOT check the process param. > > The patch will check the param and display a user error message gracefully. > > > > Steps to reproduce the issue. > > 1. $ emacs -q /tmp/a.py # start emacs and open a python source file > > 2. type "C-c C-p" (or M-x run-python) to start a python shell > > 3. type exit() to stop the python process but the buffer still exists > > 4. Switch to *python* buffer, then M-x > > python-shell-completion-at-point will get the error message > > > > Please help review the patch. Thanks. Regards > > > > > > From aa44c95c7f13f2d68be83260e618cf4d806b313b Mon Sep 17 00:00:00 2001 > > From: Lin Sun > > Date: Wed, 1 May 2024 06:55:31 +0000 > > Subject: [PATCH] ; Check the process param in function > > (python-shell-completion-at-point) > > > > * lisp/progmodes/python.el (python-shell-completion-at-point): > > Check the process param at the beginning of the function. > > --- > > lisp/progmodes/python.el | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el > > index d6c29e5ffc..4b2e2f8215 100644 > > --- a/lisp/progmodes/python.el > > +++ b/lisp/progmodes/python.el > > @@ -4708,6 +4708,8 @@ python-shell-completion-at-point > > Optional argument PROCESS forces completions to be retrieved > > using that one instead of current buffer's process." > > (setq process (or process (get-buffer-process (current-buffer)))) > > + (unless process > > + (user-error "No active python inferior process")) > > (let* ((is-shell-buffer (derived-mode-p 'inferior-python-mode)) > > (line-start (if is-shell-buffer > > ;; Working on a shell buffer: use prompt end. > > -- > > 2.20.5 > > Hi Kobarity, Please help review the patch for checking process and > emitting user-error when it's not available. Thanks. Hi Lin, The patch itself looks good to me. > > 4. Switch to *python* buffer, then M-x > > python-shell-completion-at-point will get the error message As `python-shell-completion-at-point' is not an interactive function, I tested with M-x complete-symbol.