From 47adcbafc07b833918948092093e1d6e7e1cfe13 Mon Sep 17 00:00:00 2001 From: Thomas Wouters Date: Tue, 16 Jan 2001 06:35:14 +0000 Subject: 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.) --- Lib/nntplib.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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__()). -- cgit v0.12