~ubuntu-branches/ubuntu/precise/python3.2/precise-proposed

« back to all changes in this revision

Viewing changes to Lib/nntplib.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-03-09 18:40:39 UTC
  • mfrom: (30.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120309184039-j3yk2emxr1plyo21
Tags: 3.2.3~rc1-1
* Python 3.2.3 release candidate 1.
* Update to 20120309 from the 3.2 branch.
* Fix libpython.a symlink. Closes: #660146.
* Build-depend on xauth.
* Run the gdb tests for the debug build only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
324
324
        self.debugging = 0
325
325
        self.welcome = self._getresp()
326
326
 
 
327
        # Inquire about capabilities (RFC 3977).
 
328
        self._caps = None
 
329
        self.getcapabilities()
 
330
 
327
331
        # 'MODE READER' is sometimes necessary to enable 'reader' mode.
328
332
        # However, the order in which 'MODE READER' and 'AUTHINFO' need to
329
333
        # arrive differs between some NNTP servers. If _setreadermode() fails
330
334
        # with an authorization failed error, it will set this to True;
331
335
        # the login() routine will interpret that as a request to try again
332
336
        # after performing its normal function.
 
337
        # Enable only if we're not already in READER mode anyway.
333
338
        self.readermode_afterauth = False
334
 
        if readermode:
 
339
        if readermode and 'READER' not in self._caps:
335
340
            self._setreadermode()
 
341
            if not self.readermode_afterauth:
 
342
                # Capabilities might have changed after MODE READER
 
343
                self._caps = None
 
344
                self.getcapabilities()
336
345
 
337
346
        # RFC 4642 2.2.2: Both the client and the server MUST know if there is
338
347
        # a TLS session active.  A client MUST NOT attempt to start a TLS
339
348
        # session if a TLS session is already active.
340
349
        self.tls_on = False
341
350
 
342
 
        # Inquire about capabilities (RFC 3977).
343
 
        self._caps = None
344
 
        self.getcapabilities()
345
 
 
346
351
        # Log in and encryption setup order is left to subclasses.
347
352
        self.authenticated = False
348
353
 
364
369
            self.nntp_implementation = None
365
370
            try:
366
371
                resp, caps = self.capabilities()
367
 
            except NNTPPermanentError:
 
372
            except (NNTPPermanentError, NNTPTemporaryError):
368
373
                # Server doesn't support capabilities
369
374
                self._caps = {}
370
375
            else:
941
946
                resp = self._shortcmd('authinfo pass ' + password)
942
947
                if not resp.startswith('281'):
943
948
                    raise NNTPPermanentError(resp)
 
949
        # Capabilities might have changed after login
 
950
        self._caps = None
 
951
        self.getcapabilities()
944
952
        # Attempt to send mode reader if it was requested after login.
945
 
        if self.readermode_afterauth:
 
953
        # Only do so if we're not in reader mode already.
 
954
        if self.readermode_afterauth and 'READER' not in self._caps:
946
955
            self._setreadermode()
 
956
            # Capabilities might have changed after MODE READER
 
957
            self._caps = None
 
958
            self.getcapabilities()
947
959
 
948
960
    def _setreadermode(self):
949
961
        try: