File tree 3 files changed +8
-1
lines changed
3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -262,7 +262,7 @@ def expanduser(path):
262
262
except KeyError :
263
263
return path
264
264
userhome = pwent .pw_dir
265
- userhome = userhome .rstrip ('/' )
265
+ userhome = userhome .rstrip ('/' ) or userhome
266
266
return userhome + path [i :]
267
267
268
268
Original file line number Diff line number Diff line change @@ -345,6 +345,11 @@ def test_expanduser(self):
345
345
self .assert_ (isinstance (posixpath .expanduser ("~root/" ), basestring ))
346
346
self .assert_ (isinstance (posixpath .expanduser ("~foo/" ), basestring ))
347
347
348
+ orig_home = os .environ ['HOME' ]
349
+ os .environ ['HOME' ] = '/'
350
+ self .assertEqual (posixpath .expanduser ("~" ), "/" )
351
+ os .environ ['HOME' ] = orig_home
352
+
348
353
self .assertRaises (TypeError , posixpath .expanduser )
349
354
350
355
def test_expandvars (self ):
Original file line number Diff line number Diff line change @@ -212,6 +212,8 @@ Core and Builtins
212
212
Library
213
213
-------
214
214
215
+ - Issue 5471: Fix os.path.expanduser() for $HOME set to '/'.
216
+
215
217
- Issue 1326077: fix the formatting of SyntaxErrors by the traceback module.
216
218
217
219
- Issue 1726172: fix IndexError in the case of and empty response in ftplib.
You can’t perform that action at this time.
0 commit comments