Message75395
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). |
|
Date |
User |
Action |
Args |
2008-10-30 22:55:53 | vstinner | set | recipients:
+ vstinner, barry, hdima, amaury.forgeotdarc, orsenthil |
2008-10-30 22:55:52 | vstinner | set | messageid: <1225407352.92.0.731565278274.issue3714@psf.upfronthosting.co.za> |
2008-10-30 22:54:52 | vstinner | link | issue3714 messages |
2008-10-30 22:54:49 | vstinner | create | |
|