Skip to content

gh-136858: Adds an example of writing a tarfile using stdin #137510

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aeurielesn
Copy link
Contributor

@aeurielesn aeurielesn commented Aug 7, 2025

  • Adds an example of extracting a tar archive using the with statement.
  • Adds an example of extracting a gzip-compressed tar archive from standard input.
  • Adds an example of creating a gzip-compressed tar archive from standard input.
  • Fixes a wrong reference to TarFile.add instead of TarFile.open.


📚 Documentation preview 📚: https://cpython-previews--137510.org.readthedocs.build/

Copy link
Member

@orsenthil orsenthil left a comment

Choose a reason for hiding this comment

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

I am not sure if this PR adds high value the content. We could drop it.

@@ -104,7 +104,7 @@ Some facts and figures:
| ``'w'`` or | Open for uncompressed writing. |
| ``'w:'`` | |
+------------------+---------------------------------------------+
| ``'w:gz'`` | Open for gzip compressed writing. |
| ``'w:gz'`` | Open for gzip-compressed writing. |
Copy link
Member

Choose a reason for hiding this comment

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

Why are you hyphenating these? The following line has bzip2 compressed without hyphens.

How to create and write an archive to stdout using
:data:`sys.stdout.buffer <sys.stdout>` in the *fileobj* parameter
in :meth:`TarFile.add`::
in :meth:`TarFile.open`::
Copy link
Member

Choose a reason for hiding this comment

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

This demonstrates .add not open.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add does not have a fileobj parameter.

@@ -1367,6 +1367,12 @@ How to extract an entire tar archive to the current working directory::
tar.extractall(filter='data')
tar.close()

The same example using the :keyword:`with` statement::
Copy link
Member

Choose a reason for hiding this comment

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

You could replace the example with the with statement. We don't need an additional example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should drop it as well in the "Writing examples" section.

@bedevere-app
Copy link

bedevere-app bot commented Aug 7, 2025

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 phrase I 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.

@aeurielesn
Copy link
Contributor Author

It's fine by me if we drop it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants