Skip to content

gh-68164: Set the "regular file" bit in zipfile's writestr#134232

Open
thatch wants to merge 2 commits into
python:mainfrom
thatch:file-mode
Open

gh-68164: Set the "regular file" bit in zipfile's writestr#134232
thatch wants to merge 2 commits into
python:mainfrom
thatch:file-mode

Conversation

@thatch
Copy link
Copy Markdown
Contributor

@thatch thatch commented May 19, 2025

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented May 19, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@thatch
Copy link
Copy Markdown
Contributor Author

thatch commented May 19, 2025

@vstinner trivial change for writestr from 10-year-old bugreport

I left the ZipInfo default alone -- anyone using ZipInfo.from_file already sets this bit, and changing the default breaks anyone trying to set the symlink bit with | (as even cpython's test suite does)

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 24, 2026
@serhiy-storchaka serhiy-storchaka self-requested a review May 18, 2026 15:54
Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM, but I am not sure whether it was necessary to use named constants.

Comment thread Lib/zipfile/__init__.py
self.compress_type = archive.compression
self.compress_level = archive.compresslevel
if self.filename.endswith('/'): # pragma: no cover
self.external_attr = 0o40775 << 16 # drwxrwxr-x
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it is fine to use the hardcoded value. It is the same on all supported platforms.

@serhiy-storchaka serhiy-storchaka added needs backport to 3.15 pre-release feature fixes, bugs and security fixes and removed stale Stale PR or inactive for long period of time. labels May 18, 2026
@thatch
Copy link
Copy Markdown
Contributor Author

thatch commented May 18, 2026

Would you like me to change the constants back, rebase, etc -- or is this already in your merge queue?

@serhiy-storchaka
Copy link
Copy Markdown
Member

I just want to hear your arguments. If this is not important to you, then I would prefer to return to hardcoded constants, for smaller diff.

@thatch
Copy link
Copy Markdown
Contributor Author

thatch commented May 19, 2026

Will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants