]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.10] GH-87235: Make sure "python /dev/fd/9 9</path/to/script.py" works on macOS...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 28 Mar 2023 12:13:37 +0000 (05:13 -0700)
committerGitHub <noreply@github.com>
Tue, 28 Mar 2023 12:13:37 +0000 (14:13 +0200)
commit5ae5ea8375b6ad1fad1fa4c529980ee245250c70
tree9d623b587d14ed0eeebbf4b22536af4538cdf368
parentaae84a0e849adc7486115b72e082e6896eebc3d5
[3.10] GH-87235: Make sure "python /dev/fd/9 9</path/to/script.py" works on macOS (GH-99768) (#99817)

On macOS all file descriptors for a particular file in /dev/fd
share the same file offset, that is ``open("/dev/fd/9", "r")`` behaves
more like ``dup(9)`` than a regular open.

This causes problems when a user tries to run "/dev/fd/9" as a script
because zipimport changes the file offset to try to read a zipfile
directory. Therefore change zipimport to reset the file offset after
trying to read the zipfile directory.
(cherry picked from commit d08fb257698e3475d6f69bb808211d39e344e5b2)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
* Regen zipimport

---------

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Lib/test/test_cmd_line_script.py
Lib/zipimport.py
Misc/NEWS.d/next/macOS/2022-11-25-09-23-20.gh-issue-87235.SifjCD.rst [new file with mode: 0644]
Python/importlib_zipimport.h