diff --git a/Doc/library/netrc.rst b/Doc/library/netrc.rst --- a/Doc/library/netrc.rst +++ b/Doc/library/netrc.rst @@ -40,13 +40,17 @@ netrc Objects A :class:`netrc` instance has the following methods: -.. method:: netrc.authenticators(host) +.. method:: netrc.authenticators(host[, login]) Return a 3-tuple ``(login, account, password)`` of authenticators for *host*. If the netrc file did not contain an entry for the given host, return the tuple associated with the 'default' entry. If neither matching host nor default entry is available, return ``None``. + If *login* is given, only return a tuple for this login. If no + entry in the netrc file matches the requested combination of *host* + and *login*, return ``None``. + .. method:: netrc.__repr__() diff --git a/Lib/netrc.py b/Lib/netrc.py --- a/Lib/netrc.py +++ b/Lib/netrc.py @@ -95,7 +95,11 @@ class netrc: file, lexer.lineno) def authenticators(self, host, login=None): - """Return a (user, account, password) tuple for given host.""" + """Return a (user, account, password) tuple for given host. + + When provided, the optional login argument selects a tuple + with a matching user name. + """ if host in self.hosts: if login: for a in self.allhosts[host]: