Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.11] GH-87235: Make sure "python /dev/fd/9 9</path/to/script.py" works on macOS (GH-99768) #99816

Merged
merged 1 commit into from
Nov 27, 2022

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Nov 27, 2022

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 d08fb25)

Co-authored-by: Ronald Oussoren [email protected]

…ks on macOS (pythonGH-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 d08fb25)

Co-authored-by: Ronald Oussoren <[email protected]>
Copy link
Contributor

@ronaldoussoren ronaldoussoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@miss-islington miss-islington merged commit e4cfdaa into python:3.11 Nov 27, 2022
@miss-islington miss-islington deleted the backport-d08fb25-3.11 branch November 27, 2022 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants