-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
bpo-37144: Convert path-like object to regular path #13817
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
Changes from 1 commit
7cfe617
a307164
9d34011
cd73f1e
cb85402
dd30c0d
82882dd
14ae149
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1468,7 +1468,9 @@ def __init__(self, name=None, mode="r", fileobj=None, format=None, | |
| if hasattr(fileobj, "mode"): | ||
| self._mode = fileobj.mode | ||
| self._extfileobj = True | ||
| self.name = os.fspath(name) if name else None | ||
|
|
||
| name = os.fspath(name) if name else None | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this line before Both functions accept
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asvetlov |
||
| self.name = os.path.abspath(name) if name else None | ||
| self.fileobj = fileobj | ||
|
|
||
| # Init attributes. | ||
|
|
@@ -1938,12 +1940,13 @@ def add(self, name, arcname=None, recursive=True, *, filter=None): | |
| excluded from the archive. | ||
| """ | ||
| self._check("awx") | ||
| name = os.fspath(name) | ||
|
|
||
| if arcname is None: | ||
| arcname = name | ||
|
|
||
| # Skip if somebody tries to archive the archive... | ||
| if self.name is not None and os.fspath(name) == self.name: | ||
| if self.name is not None and os.path.abspath(name) == self.name: | ||
| self._dbg(2, "tarfile: Skipped %r" % name) | ||
| return | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1422,9 +1422,10 @@ def test_file_mode(self): | |
| os.umask(original_umask) | ||
|
|
||
| def test_open_by_path_object(self): | ||
| # Test for issue #37144: broken open for stream write by path-like object | ||
| tar = tarfile.open(pathlib.Path(tmpname), self.mode) | ||
| tar.close() | ||
| # Test for issue #37144: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove these comments. |
||
| # broken open for stream write by path-like object | ||
| with tarfile.open(pathlib.Path(tmpname), self.mode): | ||
| pass | ||
|
|
||
| class GzipStreamWriteTest(GzipTest, StreamWriteTest): | ||
| pass | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line, we have to get a minimalist diff for the merge. Thank you