MINGW-packages/mingw-w64-python/0062-expanduser-normpath-paths-coming-from-env-vars.patch
2025-10-10 14:31:04 +02:00

33 lines
1.0 KiB
Diff

From f23f3fc51cd51509dd46f27852b5464972943b7c Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Sun, 8 Aug 2021 10:17:35 +0200
Subject: [PATCH 062/N] expanduser: normpath paths coming from env vars
This makes sure we get the same paths as with related functions in pathlib.
---
Lib/ntpath.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index c4855ae..f1d3333 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -380,7 +380,7 @@ def expanduser(path):
if 'USERPROFILE' in os.environ:
userhome = os.environ['USERPROFILE']
elif not 'HOMEPATH' in os.environ:
- return path
+ return os.path.normpath(path)
else:
try:
drive = os.environ['HOMEDRIVE']
@@ -407,7 +407,7 @@ def expanduser(path):
if isinstance(path, bytes):
userhome = os.fsencode(userhome)
- return userhome + path[i:]
+ return os.path.normpath(userhome) + path[i:]
# Expand paths containing shell variable substitutions.