[Python-3000] email libraries: use byte or unicode strings?

Terry Reedy tjreedy at udel.edu
Wed Oct 29 18:55:07 CET 2008


Bill Janssen wrote:
> Victor Stinner <victor.stinner at haypocalc.com> wrote:
> 
>> Note: imaplib and nntplib have no test :-(

The examples in the manual should serve as a basis for a doctest.

> I'm concerned about the lack of test suites for these modules.  They
> basically go untested unless someone sets up a server, and then runs a
> series of unscripted ad-hoc tests against that server.  Is there either
> a way we could set up IMAP and NNTP servers on python.org to test
> against, or perhaps find some effectively permanent services to test
> againt?

news.gmane.org requires no logon and has been up pretty reliably for 
years.  I presume it uses standard nntp server software.  It certainly 
works fine with both OutlookExpress and Thunderbird. 
gmane.comp.python.devel (or python-3000.devel) would be an approriate 
newsgroup to test retrieval.  gmane.test is obviously used by numerous 
people for testing posting and replies.

However...
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import nntplib as N
 >>> s=N.NNTP('news.gmane.org')

3.0rc1 fail here with string vs bytes message

 >>> resp, count, first, last, name = s.group('gmane.comp.python.devel')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "C:\Program Files\Python25\lib\nntplib.py", line 346, in group
     resp = self.shortcmd('GROUP ' + name)
   File "C:\Program Files\Python25\lib\nntplib.py", line 260, in shortcmd
     return self.getresp()
   File "C:\Program Files\Python25\lib\nntplib.py", line 215, in getresp
     resp = self.getline()
   File "C:\Program Files\Python25\lib\nntplib.py", line 207, in getline
     if not line: raise EOFError
EOFError
 >>> s.group('gmane.comp.python.general')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "C:\Program Files\Python25\lib\nntplib.py", line 346, in group
     resp = self.shortcmd('GROUP ' + name)
   File "C:\Program Files\Python25\lib\nntplib.py", line 259, in shortcmd
     self.putcmd(line)
   File "C:\Program Files\Python25\lib\nntplib.py", line 199, in putcmd
     self.putline(line)
   File "C:\Program Files\Python25\lib\nntplib.py", line 194, in putline
     self.sock.sendall(line)
   File "<string>", line 1, in sendall
socket.error: (10053, 'Software caused connection abort')

 >>> s.getwelcome()
'200 news.gmane.org InterNetNews NNRP server INN 2.4.1 ready (posting ok).'

 >>> s.set_debuglevel(2)
 >>> s.newgroups('081029','000000')
*cmd* 'NEWGROUPS 081029 000000'
*put* 'NEWGROUPS 081029 000000\r\n'
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "C:\Program Files\Python25\lib\nntplib.py", line 275, in newgroups
     return self.longcmd('NEWGROUPS ' + date + ' ' + time, file)
   File "C:\Program Files\Python25\lib\nntplib.py", line 264, in longcmd
     self.putcmd(line)
   File "C:\Program Files\Python25\lib\nntplib.py", line 199, in putcmd
     self.putline(line)
   File "C:\Program Files\Python25\lib\nntplib.py", line 194, in putline
     self.sock.sendall(line)
   File "<string>", line 1, in sendall
socket.error: (10053, 'Software caused connection abort')

I get same with 'nntp.aioe.org', so on my WinXP machine, 2.5 nntplib 
seems not to be working either.

Terry



More information about the Python-3000 mailing list