summaryrefslogtreecommitdiff
path: root/Lib/posixpath.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/posixpath.py')
-rw-r--r--Lib/posixpath.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index 1c63af8d47..7f907ef519 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -303,11 +303,11 @@ def expanduser(path):
do nothing."""
if not path.startswith('~'):
return path
- i, n = 1, len(path)
- while i < n and path[i] != '/':
- i += 1
+ i = path.find('/', 1)
+ if i < 0:
+ i = len(path)
if i == 1:
- if not 'HOME' in os.environ:
+ if 'HOME' not in os.environ:
import pwd
userhome = pwd.getpwuid(os.getuid()).pw_dir
else: