8000 bpo-31904: posixpath.expanduser() handles user home of None by pxinwr · Pull Request #23530 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-31904: posixpath.expanduser() handles user home of None #23530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/posixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ def expanduser(path):
# password database, return the path unchanged
return path
userhome = pwent.pw_dir
# if the current user has no home directory, return the path unchanged
if userhome is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not comfortable to change the behavior on any platform.

I would be ok if the change is specific to VxWorks, if you add:

Suggested change
if userhome is None:
if userhome is None and sys.platform == "vxworks":

Please update the comment and the NEWS entry to mention that only VxWorks is impacted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified.

return path
if isinstance(path, bytes):
userhome = os.fsencode(userhome)
root = b'/'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:func:`posixpath.expanduser` returns the input *path* unchanged if
user home directory is None.
0