summaryrefslogtreecommitdiffstats
path: root/Lib/nntplib.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2002-11-17 17:53:12 (GMT)
committerEric S. Raymond <esr@thyrsus.com>2002-11-17 17:53:12 (GMT)
commit782d9408667f8df924d865088839633f53cf89bc (patch)
tree8224bd2870c3337af0552a943efd1304225ba8c6 /Lib/nntplib.py
parent89350a41b969b1fb20d0e24db28a20491e448860 (diff)
downloadcpython-782d9408667f8df924d865088839633f53cf89bc.zip
cpython-782d9408667f8df924d865088839633f53cf89bc.tar.gz
cpython-782d9408667f8df924d865088839633f53cf89bc.tar.bz2
Guard against error if .netrc is missing.
Diffstat (limited to 'Lib/nntplib.py')
-rw-r--r--Lib/nntplib.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index 618e4b8..ea831cf 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)