diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2017-11-25 10:37:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-25 10:37:22 (GMT) |
commit | 8d9bb11d8fcbf10cc9b1eb0a647bcf3658a4e3dd (patch) | |
tree | 96a2d24856b7ea63dfb3992125e3e90447ab52fb /Doc/library/netrc.rst | |
parent | 9d5ec808de2c1359f434cc2fa8378458e4339c96 (diff) | |
download | cpython-8d9bb11d8fcbf10cc9b1eb0a647bcf3658a4e3dd.zip cpython-8d9bb11d8fcbf10cc9b1eb0a647bcf3658a4e3dd.tar.gz cpython-8d9bb11d8fcbf10cc9b1eb0a647bcf3658a4e3dd.tar.bz2 |
bpo-28334: netrc() now uses expanduser() to find .netrc file (GH-4537)
Previously, netrc.netrc() was raised an exception if $HOME is not set.
Authored-By: Dimitri Merejkowsky <dimitri.merejkowsky@tanker.io>
Diffstat (limited to 'Doc/library/netrc.rst')
-rw-r--r-- | Doc/library/netrc.rst | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Doc/library/netrc.rst b/Doc/library/netrc.rst index 64aa3ac..3d29ac4 100644 --- a/Doc/library/netrc.rst +++ b/Doc/library/netrc.rst @@ -20,8 +20,10 @@ the Unix :program:`ftp` program and other FTP clients. A :class:`~netrc.netrc` instance or subclass instance encapsulates data from a netrc file. The initialization argument, if present, specifies the file to parse. If - no argument is given, the file :file:`.netrc` in the user's home directory will - be read. Parse errors will raise :exc:`NetrcParseError` with diagnostic + no argument is given, the file :file:`.netrc` in the user's home directory -- + as determined by :func:`os.path.expanduser` -- will be read. Otherwise, + a :exc:`FileNotFoundError` exception will be raised. + Parse errors will raise :exc:`NetrcParseError` with diagnostic information including the file name, line number, and terminating token. If no argument is specified on a POSIX system, the presence of passwords in the :file:`.netrc` file will raise a :exc:`NetrcParseError` if the file @@ -32,6 +34,10 @@ the Unix :program:`ftp` program and other FTP clients. .. versionchanged:: 3.4 Added the POSIX permission check. + .. versionchanged:: 3.7 + :func:`os.path.expanduser` is used to find the location of the + :file:`.netrc` file when *file* is not passed as argument. + .. exception:: NetrcParseError @@ -82,4 +88,3 @@ Instances of :class:`~netrc.netrc` have public instance variables: punctuation is allowed in passwords, however, note that whitespace and non-printable characters are not allowed in passwords. This is a limitation of the way the .netrc file is parsed and may be removed in the future. - |