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#70440: [PATCH] Use -P switch when calling 'python-interpreter' Date: Wed, 17 Apr 2024 20:23:30 +0200 Message-ID: <87h6fzj1b1.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="31364"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 70440@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 17 20:24:02 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 1rx9ww-0007z7-IS for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 17 Apr 2024 20:24:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rx9wp-0006fT-65; Wed, 17 Apr 2024 14:23:55 -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 1rx9wm-0006c2-Pb for bug-gnu-emacs@gnu.org; Wed, 17 Apr 2024 14:23:52 -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 1rx9wm-0002Bn-DV for bug-gnu-emacs@gnu.org; Wed, 17 Apr 2024 14:23:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rx9wz-0003No-2d for bug-gnu-emacs@gnu.org; Wed, 17 Apr 2024 14:24:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 17 Apr 2024 18:24:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70440 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.171337823912940 (code B ref -1); Wed, 17 Apr 2024 18:24:04 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Apr 2024 18:23:59 +0000 Original-Received: from localhost ([127.0.0.1]:47371 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rx9wr-0003MP-41 for submit@debbugs.gnu.org; Wed, 17 Apr 2024 14:23:58 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:53690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rx9wo-0003LJ-OO for submit@debbugs.gnu.org; Wed, 17 Apr 2024 14:23:56 -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 1rx9wW-0006Y9-Ba for bug-gnu-emacs@gnu.org; Wed, 17 Apr 2024 14:23:36 -0400 Original-Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rx9wU-00029k-Fx for bug-gnu-emacs@gnu.org; Wed, 17 Apr 2024 14:23:36 -0400 Original-Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a5568bef315so29818466b.1 for ; Wed, 17 Apr 2024 11:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713378212; x=1713983012; darn=gnu.org; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=9wPg521bRrBGo+8PDrIfBWcFqB6Cu0RWd5esso3cMg8=; b=GMLTjkipjzs6wKIji4VbnfCfRUepo44n4tbSyFBgQGushDMX+5+HPI3rfs1UFBCYU+ DEnGmkesDO+8Jwphm2owztl5KHCMRF36G6fGBkfJB4Me+VSC63sgF2/W0VFnh/QSo80J t9oygtZRw2+5QRgI5q1YTuNnZMVutDuMsPbKJkKev7VJpgVdKq/dGMvz1+OSwgs9k2bG wzGUPv+Ieh0vsmxAyGS8v0bHBC1IXcgn+y5LF/7eJ+l7R+CiuK4iZ48YTcWp8qxgzJDo g6heFFLn46X1F5fomoh2ckBT2AvYHrQmD2WFnmASJef/gplfUzLwXCZCbMy+0iG2m1k0 m5Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713378212; x=1713983012; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9wPg521bRrBGo+8PDrIfBWcFqB6Cu0RWd5esso3cMg8=; b=dz5TlThs+5+PGXZt0S2Xvi7rLEkNP4wHYBA12+5+xagArEPZO14C6fnUcYLSPA8LUO yMrNMWQIAE1P+YCUkKOgmuZYnPXn6lvz+RQ46pFlDeH1GzD71T1VSC8h2jdaPcssAw6O YqWspNafQ4ei0IB1idPgYxyioUnAK5YMHQDIof9mbwurcEaFV+i58I5UZppOYUlLN5tD rpdcY7CLdQ3cIgQC9yl1un6dtxCYJd8GI9hMIExobhKBQlUdPSUb7n8MZccd0PWG2Z5K 9tUOXLrDY5A9Xe3DRnv1viupLa6hFZ5JsGnYMWy5r+L7SLyNg02YG+xpqzxQ0YoZuhj6 ifUA== X-Gm-Message-State: AOJu0YwT0Nh/lSCNSOodAEAqxYxDhhKwKTGtTRjNL9bucqHyZfcGjZDF UZ2KigPBMePk0gztLM+ovoZRF/K20VtpMX0zMijzwA5KoCjUBy0d3nGp2g== X-Google-Smtp-Source: AGHT+IGiV7S7bhMFJZAxFdhc4iAsrcgcSoNmSzN83SHaGwWHDdWsPNzO7xq/T5ADBPpPZhAzMyumVg== X-Received: by 2002:a17:907:7256:b0:a55:622c:7e with SMTP id ds22-20020a170907725600b00a55622c007emr1661365ejc.36.1713378212272; Wed, 17 Apr 2024 11:23:32 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8a87:ff00::6223]) by smtp.gmail.com with ESMTPSA id cx10-20020a170906c80a00b00a51b5282837sm8437472ejb.15.2024.04.17.11.23.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 11:23:31 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=arstoffel@gmail.com; helo=mail-ej1-x633.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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283515 Archived-At: --=-=-= Content-Type: text/plain Tags: patch The attachment should be self-explanatory, otherwise let me know. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Use-P-switch-when-calling-python-interpreter.patch >From 04db8a3fbb29f497fdc728f4413aea162650b30b Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Wed, 17 Apr 2024 20:17:22 +0200 Subject: [PATCH] Use -P switch when calling 'python-interpreter' This excludes the current directory from Python's module load path, which can be unsafe. * lisp/progmodes/python.el (python--list-imports): Use -P switch (python--do-isort): Use -P switch (python-fix-imports): Use -P switch --- lisp/progmodes/python.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 85279d3e84b..180a8357aad 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -6805,7 +6805,7 @@ python--list-imports (append (split-string-shell-command python-interpreter-args) - `("-c" ,python--list-imports) + `("-Pc" ,python--list-imports) (list (or name ""))))) (with-current-buffer buffer (apply #'call-process @@ -6814,7 +6814,7 @@ python--list-imports (append (split-string-shell-command python-interpreter-args) - `("-c" ,python--list-imports) + `("-Pc" ,python--list-imports) (list (or name "")) (mapcar #'file-local-name source)))))) lines) @@ -6862,7 +6862,7 @@ python--do-isort (append (split-string-shell-command python-interpreter-args) - '("-m" "isort" "-") + '("-Pm" "isort" "-") args))) (tick (buffer-chars-modified-tick))) (unless (eq 0 status) @@ -6940,7 +6940,7 @@ python-fix-imports (append (split-string-shell-command python-interpreter-args) - '("-m" "pyflakes")))) + '("-Pm" "pyflakes")))) (goto-char (point-min)) (when (looking-at-p ".* No module named pyflakes$") (error "%s couldn't find pyflakes" python-interpreter)) -- 2.44.0 --=-=-=--