Skip to content

bpo-21987: fix TarFile.getmember getting a dir with a trailing slash - #30283

Merged
serhiy-storchaka merged 4 commits into
python:mainfrom
akulakov:21987-Fix-tarfile-getmember-trailing-slash
Jan 21, 2022
Merged

serhiy-storchaka merged 4 commits into
python:mainfrom
akulakov:21987-Fix-tarfile-getmember-trailing-slash

Conversation

@akulakov

@akulakov akulakov commented Dec 28, 2021 •

Copy link
Copy Markdown
Contributor

https://bugs.python.org/issue21987

Co-authored with Matt Behrens

Comment thread Lib/test/test_tarfile.py Outdated
self.add_dir_and_getmember('a'*101)

def add_dir_and_getmember(self, name):
tar = tarfile.open(tmpname, 'w')

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.

Use context managers.

You can use temp_cwd() and temp_dir() from test.support.os_helper for creating temporary dirs.

Comment thread Lib/test/test_tarfile.py Outdated
Comment on lines +237 to +238
tar.getmember(name)
tar.getmember(name + '/')

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.

Maybe test that these two return the same info.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @akulakov for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 21, 2022
…ythonGH-30283)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 21, 2022
…ythonGH-30283)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

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

miss-islington added a commit that referenced this pull request Jan 21, 2022
…H-30283)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
@akulakov
akulakov deleted the 21987-Fix-tarfile-getmember-trailing-slash branch January 21, 2022 12:45
@akulakov

akulakov commented Jan 21, 2022 •

Copy link
Copy Markdown
Contributor Author

Serhiy and Jelle, thanks for reviewing!

serhiy-storchaka pushed a commit that referenced this pull request Jan 23, 2022
…slash (GH-30283) (GH-30738)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…slash (pythonGH-30283) (pythonGH-30738)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants