Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 10 additions & 4 deletions Lib/posixpath.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -388,11 +388,17 @@ def abspath(path):
"""Return an absolute path."""
path = os.fspath(path)
if isinstance(path, bytes):
if not path.startswith(b'/'):
path = join(os.getcwdb(), path)
sep = b'/'
curdir = b'.'
getcwd = os.getcwdb
else:
if not path.startswith('/'):
path = join(os.getcwd(), path)
sep = '/'
curdir = '.'
getcwd = os.getcwd
if not path.startswith(sep):
if not path or path == curdir:
Comment thread
nineteendo marked this conversation as resolved.
return getcwd()
path = join(getcwd(), path)
return normpath(path)


Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Speedup :func:`os.path.abspath()` by up to 13% on Unix for "" & ".".