Bug #1566602: correct failure of posixpath unittest when $HOME ends
with a slash.
 (backport from rev. 52065)
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index 9eac6bc..b396f0a 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -328,8 +328,7 @@
         except KeyError:
             return path
         userhome = pwent.pw_dir
-    if userhome.endswith('/'):
-        i += 1
+    userhome = userhome.rstrip('/')
     return userhome + path[i:]