This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.araujo
Recipients corona10, eric.araujo, ned.deily, petr.viktorin, shihai1991
Date 2020-10-21.20:18:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1603311520.33.0.000221158916763.issue41626@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-10-21 20:18:40eric.araujosetrecipients: + eric.araujo, ned.deily, petr.viktorin, corona10, shihai1991
2020-10-21 20:18:40eric.araujosetmessageid: <1603311520.33.0.000221158916763.issue41626@roundup.psfhosted.org>
2020-10-21 20:18:40eric.araujolinkissue41626 messages
2020-10-21 20:18:39eric.araujocreate