This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients amaury.forgeotdarc, barry, hdima, orsenthil, vstinner
Date 2008-10-30.22:54:45
SpamBayes Score 4.3687276e-14
Marked as misclassified No
Message-id <1225407352.92.0.731565278274.issue3714@psf.upfronthosting.co.za>
In-reply-to
Content
After testing many different emails servers (POP3, IMAP4 and NNTP), I 
think that the best type is bytes and not str (unicode). Attached 
patch changes nntplib to use bytes:
 - write tests using Gmane NNTP public server
 - use bytes everywhere except for the commands (str), converted to 
bytes using ASCII charset
 - factorizy post() + ihave(): create _post()
 - replace line[-1] == '\n' by line.endswith(b'\n')
 - replace e.response[:3] == '480' by e.response.startswith(b'480')
 - use format() method because str+int is forbidden. Eg. see body() 
method: id can be an integer (or an unicode string).

I like startswith() / endswith() because it's more readable and it 
works with string of 1 byte: line[-1:] == b'\n' vs 
line.endswith(b'\n').

TODO:
 - test authentication
 - test methods marked as "TODO" in the testcase: 
    * Check newgroups(), newnews(), list()
    * Check xhdr(), xover(), xgtitle(), xpath()
    * Check post(), ihave()
 - does .format() work with bytes? body(b'1') may creates the 
command "BODY b'1'" which is wrong <= should I also use bytes for the 
commands?

I don't know NNTP enough to test all methods, and I don't have any 
account to test the authentication :-/ But most common commands should 
work (see the testcase).
History
Date User Action Args
2008-10-30 22:55:53vstinnersetrecipients: + vstinner, barry, hdima, amaury.forgeotdarc, orsenthil
2008-10-30 22:55:52vstinnersetmessageid: <1225407352.92.0.731565278274.issue3714@psf.upfronthosting.co.za>
2008-10-30 22:54:52vstinnerlinkissue3714 messages
2008-10-30 22:54:49vstinnercreate