New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
poplib module broken by str to unicode conversion #47977
Comments
Example: >>> from poplib import POP3
>>> p = POP3("localhost")
>>> p.user("user")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/py3k/Lib/poplib.py", line 179, in user
return self._shortcmd('USER %s' % user)
File "/py3k/Lib/poplib.py", line 151, in _shortcmd
self._putcmd(line)
File "/py3k/Lib/poplib.py", line 98, in _putcmd
self._putline(line)
File "/py3k/Lib/poplib.py", line 91, in _putline
self.sock.sendall('%s%s' % (line, CRLF))
TypeError: sendall() argument 1 must be string or buffer, not str
>>> p.user(b"user")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/py3k/Lib/poplib.py", line 179, in user
return self._shortcmd('USER %s' % user)
File "/py3k/Lib/poplib.py", line 151, in _shortcmd
self._putcmd(line)
File "/py3k/Lib/poplib.py", line 98, in _putcmd
self._putline(line)
File "/py3k/Lib/poplib.py", line 91, in _putline
self.sock.sendall('%s%s' % (line, CRLF))
TypeError: sendall() argument 1 must be string or buffer, not str |
Here is a patch proposition:
Test updates:
Missing: no SSL unit test. I tested SSL on my personal POP3 account, |
Ooops, my previous patch was wrong (startswith => not startswith). I tested python trunk test for poplib: with minor changes, all tests About EBADF error from select(), it may comes from missing makefile() |
New version:
poplib should be refactored to reuse the new IO library. But I don't |
I haven't tried the patch but I think that "encoding" should be a class |
New version:
Finally my patch removes more code in poplib.py than it adds :-D I Python3 new I/O library rocks! |
@giampaolo.rodola: Right, I also prefer encoding as a class attribute.
|
I like this patch. |
Oooops, I removed the message74562 from giampaolo.rodola, sorry: |
After testing real world message, my patch using pure unicode doesn't |
New patch: resp() returns bytes
The default charset is UTF-8, but most servers only accept pure ASCII welcome attribute (and getwelcome() results) is a bytes string. You have to parse the message headers to get the right charset to Arguments (username (login), password, a message identifier) are I hope that apop() works. No Python error is raised but no server does |
About apop(): the second argument is the user password, not a "shared |
I forgot the new unit tests. New patch:
|
Can anyone review my last patch (poplib-bytes-2.patch)? |
I'm happy with Victor's patch. |
Benjamin's reviewed this and the only thing that jumps out at me is some |
Le Tuesday 04 November 2008 01:03:42 Barry A. Warsaw, vous avez écrit :
It's not related to my patch (I did'nt change POP3_SSL comment). But well, as |
Patch applied in r67109 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: