summarylogtreecommitdiffstats
path: root/0134-expanduser-normpath-paths-coming-from-env-vars.patch
blob: 9b7fb03aa16acd6aaa2a36a9a73ace2a7c064fb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 6f3a083adc2e679029614ecb2ce4aa2f066324b1 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 134/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 77f5614..5d1c6b9 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -319,7 +319,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']
@@ -333,7 +333,7 @@ def expanduser(path):
     if i != 1: #~user
         userhome = join(dirname(userhome), path[1:i])
 
-    return userhome + path[i:]
+    return os.path.normpath(userhome) + path[i:]
 
 
 # Expand paths containing shell variable substitutions.
-- 
2.32.0