summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/ntpath.py4
-rw-r--r--Misc/NEWS.d/3.13.0a6.rst2
2 files changed, 4 insertions, 2 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index da5231f..f5d1a21 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -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
if 'USERPROFILE' in os.environ:
diff --git a/Misc/NEWS.d/3.13.0a6.rst b/Misc/NEWS.d/3.13.0a6.rst
index 52735db..06807b3 100644
--- a/Misc/NEWS.d/3.13.0a6.rst
+++ b/Misc/NEWS.d/3.13.0a6.rst
@@ -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`.
..