Skip to content
Merged
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
4 changes: 3 additions & 1 deletion Lib/ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,15 @@ def expanduser(path):
If user or $HOME is unknown, do nothing."""
path = os.fspath(path)
if isinstance(path, bytes):
seps = b'\\/'
tilde = b'~'
else:
seps = '\\/'
tilde = '~'
if not path.startswith(tilde):
return path
i, n = 1, len(path)
while i < n and path[i] not in _get_bothseps(path):
while i < n and path[i] not in seps:
i += 1
Comment thread
nineteendo marked this conversation as resolved.

if 'USERPROFILE' in os.environ:
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.13.0a6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.. release date: 2024-04-09
.. section: Core and Builtins

Improve performance of :func:`os.path.join`.
Improve performance of :func:`os.path.join` and :func:`os.path.expanduser`.

..

Expand Down