]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-87235: Make sure "python /dev/fd/9 9</path/to/script.py" works on macOS (GH-99768)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 27 Nov 2022 11:19:02 +0000 (03:19 -0800)
committerGitHub <noreply@github.com>
Sun, 27 Nov 2022 11:19:02 +0000 (03:19 -0800)
commite4cfdaa45b5fe25ce27c63c9bed383a0f0d4abe9
treeeb517c3f852c1d90524c3d1afa93c75f21b829d6
parent8bb7fdaee8c19f0311f15dbea7f8eee80a67a50f
GH-87235: Make sure "python /dev/fd/9 9</path/to/script.py" works on macOS (GH-99768)

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>
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]