◐ Shell
reader mode source ↗
Skip to content

bpo-45863: tarfile: don't zero out header fields unnecessarily#29693

Merged
vstinner merged 2 commits into
python:mainfrom
jmroot:tarfile-headers
Feb 9, 2022
Merged

bpo-45863: tarfile: don't zero out header fields unnecessarily#29693
vstinner merged 2 commits into
python:mainfrom
jmroot:tarfile-headers

Conversation

@jmroot

@jmroot jmroot commented Nov 22, 2021

Copy link
Copy Markdown
Contributor

Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

https://bugs.python.org/issue45863

@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 Dec 23, 2021
@jmroot

jmroot commented Jan 13, 2022

Copy link
Copy Markdown
Contributor Author

Commenting to clear stale flag since this is still awaiting review.

@jmroot

jmroot commented Feb 5, 2022

Copy link
Copy Markdown
Contributor Author

@vstinner Changes made to address concerns brought up in our conversation on IRC.

Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
@jmroot jmroot requested a review from vstinner February 8, 2022 10:27
@vstinner

vstinner commented Feb 9, 2022

Copy link
Copy Markdown
Member

Can you please add a NEWS entry for this change? See for blurb or blurb-it.

With no NEWS, I'm ok to merge the change in main, but not to backport it.

@jmroot

jmroot commented Feb 9, 2022

Copy link
Copy Markdown
Contributor Author

Happy to write a NEWS entry, but TBH I was put off by the tool dependencies apparently needed to generate the required filename.

@jmroot

jmroot commented Feb 9, 2022

Copy link
Copy Markdown
Contributor Author

OK, I see now that blurb-it is an option, which is at least a little more convenient than installing blurb locally.

@jmroot

jmroot commented Feb 9, 2022

Copy link
Copy Markdown
Contributor Author

Sorry for manually squashing and force pushing BTW, I initially missed the part in the docs where it says not to.

@jmroot

jmroot commented Feb 9, 2022

Copy link
Copy Markdown
Contributor Author

@vstinner News entry added and CI has passed.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @jmroot for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @jmroot for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-bot

Copy link
Copy Markdown

GH-31232 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 9, 2022
…nGH-29693)

Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
(cherry picked from commit bf2d44f)

Co-authored-by: Joshua Root <jmr@macports.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 9, 2022
…nGH-29693)

Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
(cherry picked from commit bf2d44f)

Co-authored-by: Joshua Root <jmr@macports.org>
@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Feb 9, 2022
@bedevere-bot

Copy link
Copy Markdown

GH-31233 is a backport of this pull request to the 3.10 branch.

miss-islington added a commit that referenced this pull request Feb 9, 2022
)

Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
(cherry picked from commit bf2d44f)

Co-authored-by: Joshua Root <jmr@macports.org>
miss-islington added a commit that referenced this pull request Feb 9, 2022
)

Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
(cherry picked from commit bf2d44f)

Co-authored-by: Joshua Root <jmr@macports.org>
@jmroot jmroot deleted the tarfile-headers branch February 9, 2022 21:36
@jmroot

jmroot commented Feb 9, 2022

Copy link
Copy Markdown
Contributor Author

Thanks!

hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…nGH-29693)

Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
(cherry picked from commit bf2d44f)

Co-authored-by: Joshua Root <jmr@macports.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants