bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#70440: [PATCH] Use -P switch when calling 'python-interpreter'


From: kobarity
Subject: bug#70440: [PATCH] Use -P switch when calling 'python-interpreter'
Date: Fri, 19 Apr 2024 00:25:46 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (Gojō) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Eli Zaretskii wrote:
> > From: Augusto Stoffel <arstoffel@gmail.com>
> > Date: Wed, 17 Apr 2024 20:23:30 +0200
> > 
> > The attachment should be self-explanatory, otherwise let me know.
> > 
> > 
> > >From 04db8a3fbb29f497fdc728f4413aea162650b30b Mon Sep 17 00:00:00 2001
> > From: Augusto Stoffel <arstoffel@gmail.com>
> > 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
> > 
> 
> Thanks.
> 
> kobarity, any comments?

The -P switch is new, introduced in CPython 3.11, so I don't think it
can be added unconditionally.  Furthermore, `python-interpreter' may
not be CPython.  Isn't it enough to customize
`python-interpreter-args'?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]