From: Eric S. Raymond Date: Sun, 17 Nov 2002 17:53:12 +0000 (+0000) Subject: Guard against error if .netrc is missing. X-Git-Tag: v2.3c1~3381 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=782d9408667f8df924d865088839633f53cf89bc;p=python Guard against error if .netrc is missing. --- diff --git a/Lib/nntplib.py b/Lib/nntplib.py index 618e4b8d0a..ea831cf525 100644 --- a/Lib/nntplib.py +++ b/Lib/nntplib.py @@ -135,13 +135,16 @@ class NNTP: raise # If no login/password was specified, try to get them from ~/.netrc # Presume that if .netc has an entry, NNRP authentication is required. - if not user: - import netrc - credentials = netrc.netrc() - auth = credentials.authenticators(host) - if auth: - user = auth[0] - password = auth[2] + try: + if not user: + import netrc + credentials = netrc.netrc() + auth = credentials.authenticators(host) + if auth: + user = auth[0] + password = auth[2] + except IOError: + pass # Perform NNRP authentication if needed. if user: resp = self.shortcmd('authinfo user '+user)