Skip to content

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

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change os.path.abspath on os.fspath
  • Loading branch information
0x29a committed Jun 5, 2019
commit cd73f1e9782a0b594e769ef12dfc7ad546a35329
4 changes: 2 additions & 2 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ 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.path.abspath(name) if name else None
self.name = os.fspath(name) if name else None
Copy link
Contributor

Choose a reason for hiding this comment

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

these lines are not equal.
The correct code should be something like:

name = os.fspath(name)
self.name = os.path.abspath(name)

I've skipped the check for empty/None name.

self.fileobj = fileobj

# Init attributes.
Expand Down Expand Up @@ -1943,7 +1943,7 @@ def add(self, name, arcname=None, recursive=True, *, filter=None):
arcname = name

# Skip if somebody tries to archive the archive...
if self.name is not None and os.path.abspath(name) == self.name:
if self.name is not None and os.fspath(name) == self.name:
Copy link
Contributor

Choose a reason for hiding this comment

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

the same

self._dbg(2, "tarfile: Skipped %r" % name)
return

Expand Down