[Python-checkins] r85114 - in python/branches/py3k/Lib: nntplib.py test/test_nntplib.py

antoine.pitrou python-checkins at python.org
Wed Sep 29 18:19:50 CEST 2010


Author: antoine.pitrou
Date: Wed Sep 29 18:19:50 2010
New Revision: 85114
Log:
Fix NNTP when there's a ".netrc" file
Modified:
 python/branches/py3k/Lib/nntplib.py
 python/branches/py3k/Lib/test/test_nntplib.py
Modified: python/branches/py3k/Lib/nntplib.py
==============================================================================
--- python/branches/py3k/Lib/nntplib.py	(original)
+++ python/branches/py3k/Lib/nntplib.py	Wed Sep 29 18:19:50 2010
@@ -279,11 +279,12 @@
 encoding = 'utf-8'
 errors = 'surrogateescape'
 
- def __init__(self, file, user=None, password=None,
+ def __init__(self, file, host, user=None, password=None,
 readermode=None, usenetrc=True,
 timeout=_GLOBAL_DEFAULT_TIMEOUT):
 """Initialize an instance. Arguments:
 - file: file-like object (open for read/write in binary mode)
+ - host: hostname of the server (used if `usenetrc` is True)
 - user: username to authenticate with
 - password: password to use with username
 - readermode: if true, send 'mode reader' command after
@@ -933,7 +934,7 @@
 self.port = port
 self.sock = socket.create_connection((host, port), timeout)
 file = self.sock.makefile("rwb")
- _NNTPBase.__init__(self, file, user, password,
+ _NNTPBase.__init__(self, file, host, user, password,
 readermode, usenetrc, timeout)
 
 def _close(self):
Modified: python/branches/py3k/Lib/test/test_nntplib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_nntplib.py	(original)
+++ python/branches/py3k/Lib/test/test_nntplib.py	Wed Sep 29 18:19:50 2010
@@ -12,6 +12,7 @@
 # TODO:
 # - test the `file` arg to more commands
 # - test error conditions
+# - test auth and `usenetrc`
 
 
 class NetworkedNNTPTestsMixin:
@@ -255,7 +256,7 @@
 # isn't seekable.
 file = io.BufferedRWPair(self.sio, self.sio)
 kwargs.setdefault('usenetrc', False)
- self.server = nntplib._NNTPBase(file, *args, **kwargs)
+ self.server = nntplib._NNTPBase(file, 'test.server', *args, **kwargs)
 return self.server
 
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /