Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-130819: Updatetarfile.py#_create_gnu_long_header to align with GNU Tar#130820

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
gdh1995 wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromgdh1995:fix_long_gnu_name_in_tarfile

Conversation

gdh1995
Copy link

@gdh1995gdh1995 commentedMar 4, 2025
edited by bedevere-appbot
Loading

The latesttarfile may still generate a file slightly different with the one made by GNU Tar, whenever a path name is longer than 100 bytes. So this PR tries to avoid the difference.

More details are in#130819 .

@ghost
Copy link

ghost commentedMar 4, 2025
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@gdh1995gdh1995force-pushed thefix_long_gnu_name_in_tarfile branch from24b90cf to283b34eCompareMarch 5, 2025 02:38
Copy link
Member

@picnixzpicnixz left a comment
edited
Loading

Choose a reason for hiding this comment

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

Can you motivate the choice for this? namely is there a real benefit between having an explicit user+mode rather than letting the "defaults"? And more importantly, can you cite the relevant manpage / specs where we can find this?

Note: whether this is accpeted or not, this should be treated as a feature request and not a bug IMO. As such, a What's New entry will need to be created, unless the motivation behind this change is not sufficient (in which case we would close the issue as "not planned")

Comment on lines 1193 to 1195
info["mode"] = 0o100644
info["uname"] = "root"
info["gname"] = "root"
Copy link
Member

Choose a reason for hiding this comment

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

Where in the specs are these decided?

@bedevere-app
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@picnixz
Copy link
Member

Oh btw, please reply on the issue instead of the PR (I'll repost my comment above)

@gdh1995gdh1995force-pushed thefix_long_gnu_name_in_tarfile branch 4 times, most recently from80b8591 to5282dd6CompareApril 23, 2025 08:31
@gdh1995
Copy link
Author

I have made the requested changes; please review again

@bedevere-app
Copy link

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

@bedevere-appbedevere-appbot requested a review frompicnixzApril 23, 2025 09:04
Comment on lines 909 to 910
_unames = {} # Cached mappings of uid=0 -> uname
_gnames = {} # Cached mappings of gid=0 -> gname
Copy link
Member

Choose a reason for hiding this comment

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

I prefer that we keep per-instance caches instead of per-class caches, even for 0.

Copy link
Author

Choose a reason for hiding this comment

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

Hello, sorry but there seems no availableTarFile object for_create_gnu_long_header to cache the querying result:

  • aTarFile instance does have cache members ofself._unames: Dict[uid, uname]
  • however, across the calling stack ofTarInfo.tobuf() -> TarInfo.create_gnu_header() -> TarInfo._create_gnu_long_header(), there's noTarFile argument.

If we add aTarFile intoTarInfo.tobuf(...), then this PR may break existing subclasses ofTarInfo. Is it indeed necessary?

Copy link
Author

Choose a reason for hiding this comment

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

Um, to make this cache safe for the free-threading version of CPython, I've replaced the_unames = {} with_name_uid0 = None (and_gnames = {} with_name_gid0 = None).

Do you developers have any suggestions?

Copy link
Author

Choose a reason for hiding this comment

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

@picnixz Any idea about where to put the cache object?

@gdh1995gdh1995force-pushed thefix_long_gnu_name_in_tarfile branch 2 times, most recently from47861a1 toca20885CompareMay 6, 2025 09:26
@gdh1995gdh1995force-pushed thefix_long_gnu_name_in_tarfile branch fromca20885 to02bbde5CompareMay 8, 2025 12:22
@gdh1995
Copy link
Author

I have made the requested changes; please review again.

@bedevere-app
Copy link

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

@bedevere-appbedevere-appbot requested a review frompicnixzMay 9, 2025 02:47
@@ -1708,6 +1708,15 @@ sysconfig
(Contributed by Xuehai Pan in :gh:`131799`.)


tarfile
Copy link
Member

Choose a reason for hiding this comment

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

This will need to be moved in whatsnew/3.15.rst now

Comment on lines +898 to +899
_name_uid0 = None # Cached uname of uid=0
_name_gid0 = None # Cached gname of gid=0
Copy link
Member

@picnixzpicnixzMay 9, 2025
edited
Loading

Choose a reason for hiding this comment

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

What I meant before is: why using a class variable? the issue is that once we deduceuid=0, we're stuck with it for theentire Python process.

EDIT: I didn't see you comment, my bad. Then we need to think of another solution because storing them inTarFile feels wrong. What we can do is to add a private attribute in TarInfo and populate it from TarFile. When writing, if the attribute is not set, we populate it eagerly (and thus subclasses of TarInfowill be slower but they won't be broken). Or instead, we can even just dump them with the legacy way (namely without aligning with GNU Tar). Only default TarFile and TarInfo objects will be having this new feature.

More generally, we should be able to set cached contextual information on TarInfo objects coming from a TarFile.

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

@picnixzpicnixzpicnixz requested changes

@StanFromIrelandStanFromIrelandStanFromIreland left review comments

@ethanfurmanethanfurmanAwaiting requested review from ethanfurmanethanfurman is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@gdh1995@picnixz@StanFromIreland

[8]ページ先頭

©2009-2025 Movatter.jp