bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error#10919
bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error#10919vstinner merged 3 commits intopython:masterfrom vstinner:expanduser
Conversation
* posixpath.expanduser() now returns the input path unchanged if the HOME environment variable is not set and pwd.getpwuid() raises KeyError (the current user identifier doesn't exist in the password database). * Add test_no_home_directory() to test_site.
|
I tested manually this change on my Fedora 29: The site module doesn't fail anymore. Test to ensure that site fails without the fix: Note: I had to re-clone CPython in /tmp since user 12345 is not allowed to access my $HOME directory. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM. Just added few minor suggestion for tests.
|
@vstinner I can confirm that the patch works: LGTM. |
* Add more tests to test_expanduser_home_envvar() * Fix typo: assertTrue => assertEqual * Use support.import_module()
|
@serhiy-storchaka, @izbyshev: Would you mind to review the updated PR? |
izbyshev
left a comment
There was a problem hiding this comment.
LGTM, though I'm uncertain about unexpanded paths in sysconfig (see https://bugs.python.org/issue10496#msg331115).
|
On Travis CI, the coverage job (gcc) failed with: It should be fixed by my latest commit. |
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
|
GH-10924 is a backport of this pull request to the 3.7 branch. |
…GH-10919) * posixpath.expanduser() now returns the input path unchanged if the HOME environment variable is not set and pwd.getpwuid() raises KeyError (the current user identifier doesn't exist in the password database). * Add test_no_home_directory() to test_site. (cherry picked from commit f2f4555) Co-authored-by: Victor Stinner <[email protected]>
* posixpath.expanduser() now returns the input path unchanged if the HOME environment variable is not set and pwd.getpwuid() raises KeyError (the current user identifier doesn't exist in the password database). * Add test_no_home_directory() to test_site. (cherry picked from commit f2f4555) Co-authored-by: Victor Stinner <[email protected]>
…) (GH-10925) * posixpath.expanduser() now returns the input path unchanged if the HOME environment variable is not set and pwd.getpwuid() raises KeyError (the current user identifier doesn't exist in the password database). * Add test_no_home_directory() to test_site. (cherry picked from commit f2f4555)
|
…) (GH-10930) * posixpath.expanduser() now returns the input path unchanged if the HOME environment variable is not set and pwd.getpwuid() raises KeyError (the current user identifier doesn't exist in the password database). * Add test_no_home_directory() to test_site. (cherry picked from commit f2f4555)
the HOME environment variable is not set and pwd.getpwuid() raises
KeyError (the current user identifier doesn't exist in the password
database).
https://bugs.python.org/issue10496