diff options
author | Thomas Wouters <thomas@python.org> | 2001-01-16 06:35:14 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2001-01-16 06:35:14 (GMT) |
commit | 47adcbafc07b833918948092093e1d6e7e1cfe13 (patch) | |
tree | c53b2a08a40998c24fb9ed58bee1ef3035d5cf83 /Lib | |
parent | 19030a08fbfb8596a2a3db55737828b08b378cd4 (diff) | |
download | cpython-47adcbafc07b833918948092093e1d6e7e1cfe13.zip cpython-47adcbafc07b833918948092093e1d6e7e1cfe13.tar.gz cpython-47adcbafc07b833918948092093e1d6e7e1cfe13.tar.bz2 |
Fix for SF bug #123625: some newsservers need 'authinfo' *before* 'mode
readers', others *after*. (Netscape Collabra for the first category,
INN-which-forks-nnrpd for the second.)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/nntplib.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/nntplib.py b/Lib/nntplib.py index 16716ec..1a2254c 100644 --- a/Lib/nntplib.py +++ b/Lib/nntplib.py @@ -112,12 +112,25 @@ class NNTP: self.file = self.sock.makefile('rb') self.debugging = 0 self.welcome = self.getresp() + + # 'mode reader' is sometimes necessary to enable 'reader' mode. + # However, the order in which 'mode reader' and 'authinfo' need to + # arrive differs between some NNTP servers. Try to send + # 'mode reader', and if it fails with an authorization failed + # error, try again after sending authinfo. + readermode_afterauth = 0 if readermode: try: self.welcome = self.shortcmd('mode reader') except NNTPPermanentError: # error 500, probably 'not implemented' pass + except NNTPTemporaryError, e: + if user and e.response[:3] == '480': + # Need authorization before 'mode reader' + readermode_afterauth = 1 + else: + raise if user: resp = self.shortcmd('authinfo user '+user) if resp[:3] == '381': @@ -128,6 +141,13 @@ class NNTP: 'authinfo pass '+password) if resp[:3] != '281': raise NNTPPermanentError(resp) + if readermode_afterauth: + try: + self.welcome = self.shortcmd('mode reader') + except NNTPPermanentError: + # error 500, probably 'not implemented' + pass + # Get the welcome message from the server # (this is read and squirreled away by __init__()). |