Éric Araujo <mer...@netwok.org> added the comment:

This is a minor thing, and not a particularly visible bug, but it could create 
confusion about how to run scripts so could be fixed.

1) For stdlib modules, I think the intended usage is `python3 -m 
encodings.rot_13`; I don’t expect anyone to run `python3 
/usr/lib/python3.10/encodings/rot_13.py` to do a decoding in the terminal!
So for these easter eggs / hidden gems in the stdlib, I would delete the 
shebang and remove the executable bit.  There are 18 such modules, ignoring 
test, lib2to3, turtledemo and a few others named below.

1.1) There may be some exceptions: for Lib/idlelib/pyshell.py for example, 
maybe the IDLE entry point is just a symlink to that file, and removing the 
executable bit would break it.  So this can’t be a mass update but each case 
should be reviewed.

2) Some of the files in the PR are used during development of CPython: 
Tools/clinic/clinic.py Python/makeopcodetargets.py Parser/asdl_c.py 
Objects/typeslots.py Modules/_sha3/cleanup.py 
Lib/ctypes/macholib/fetch_macholib Mac/BuildScript/build-installer.py
I think some of these work with any Python, but some need the locally built 
interpreter to give correct results.
It could avoid confusion and mistakes to remove the shebangs and executable 
bits from the scripts that need a local Python, and make dure their 
documentation mentions `./python path/to/tool`.

2.1) One recent example, Tools/peg_generator/pegen/__main__.py is documented to 
work with Python 3.8+, and confusingly is both a __main__ module (to support 
python3 -m pegen and an executable script with shebang!)

2.2) In Tools/ssl, we have `/usr/bin/env python3` in make_ssl_data.py and 
`./python` in multissltests.py.  Are these working?!

3) The files in Tools/scripts are documented as «useful for building Python» or 
«generally useful scripts».  They nearly all executable and nearly all use 
`#!/usr/bin/env python3`, so fixing the few `python` references there seems ok. 
 Likewise for Tools/pynche/pynche.

3.1) For Tools/gdb/libpython.py I don’t know how it’s meant to be used; if it’s 
not distributed but only for debugging a locally built CPython, then removing 
the shebang seems correct.

(Oh and by the way, Tools/scripts/fixps.py is a tool to replace 
`/usr/local/bin/python` shebangs with `/usr/bin/env python`…  You can judge if 
that is useful and/or correct.)


So if things are changed (let’s get a couple opinions here), maybe this needs 
separate PRs for 1/2/3, and make sure to get reviews to ensure we don’t break 
IDLE / Mac installers / pegen / etc.

----------
components: +Demos and Tools, Library (Lib)
nosy: +corona10, eric.araujo, ned.deily, petr.viktorin

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41626>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to