[issue13700] imaplib.IMAP4.authenticate authobject fails with PLAIN mechanism
New submission from Erno Tukia : >>> import imaplib >>> imap = imaplib.IMAP4_SSL("imap.example.com") >>> authcb = lambda resp: "{0}\x00{0}\x00{1}".format("username","password") >>> imap.authenticate("PLAIN", authcb) Traceback (most recent call last): File "", line 1, in imap.authenticate("PLAIN", authcb) File "/usr/lib/python3.1/imaplib.py", line 361, in authenticate typ, dat = self._simple_command('AUTHENTICATE', mech) File "/usr/lib/python3.1/imaplib.py", line 1075, in _simple_command return self._command_complete(name, self._command(name, *args)) File "/usr/lib/python3.1/imaplib.py", line 889, in _command literal = literator(self.continuation_response) File "/usr/lib/python3.1/imaplib.py", line 1238, in process return self.encode(ret) File "/usr/lib/python3.1/imaplib.py", line 1257, in encode e = binascii.b2a_base64(t) TypeError: must be bytes or buffer, not str ... and ... >>> authcb = lambda resp: >>> "{0}\x00{0}\x00{1}".format("username","password").encode() >>> imap.authenticate("PLAIN", authcb) Traceback (most recent call last): File "", line 1, in imap.authenticate("PLAIN", authcb) File "/usr/lib/python3.1/imaplib.py", line 361, in authenticate typ, dat = self._simple_command('AUTHENTICATE', mech) File "/usr/lib/python3.1/imaplib.py", line 1075, in _simple_command return self._command_complete(name, self._command(name, *args)) File "/usr/lib/python3.1/imaplib.py", line 889, in _command literal = literator(self.continuation_response) File "/usr/lib/python3.1/imaplib.py", line 1238, in process return self.encode(ret) File "/usr/lib/python3.1/imaplib.py", line 1259, in encode oup = oup + e[:-1] TypeError: Can't convert 'bytes' object to str implicitly -- components: Library (Lib) messages: 150489 nosy: etukia priority: normal severity: normal status: open title: imaplib.IMAP4.authenticate authobject fails with PLAIN mechanism type: behavior versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker <http://bugs.python.org/issue13700> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13700] imaplib.IMAP4.authenticate authobject fails with PLAIN mechanism
Erno Tukia added the comment: The same problems exists even if I use b"PLAIN" as the first argument in authenticate(). -- ___ Python tracker <http://bugs.python.org/issue13700> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13700] imaplib.IMAP4.authenticate authobject fails with PLAIN mechanism
Erno Tukia added the comment: File "/usr/lib/python3.1/imaplib.py", line 1257, in encode e = binascii.b2a_base64(t) imaplib._Authenticator.encode() calls binascii.b2a_base64() function. In Python 2.6 that function returns a string, and in Python 3.1 it returns bytes. What is returned from b2a_base64() function is later in the encode() function concatenated with a string, with bytes that is not possible. Should binascii.b2a_base64() return a string (2.6) or bytes (3.1)? -- ___ Python tracker <http://bugs.python.org/issue13700> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13700] imaplib.IMAP4.authenticate authobject fails with PLAIN mechanism
Erno Tukia added the comment: In Python 2.6 PLAIN authentication works, in Python 3.1 not. Lib/test/test_imaplib.py does not test IMAP4.authenticate() or IMAP4.login_cram_md5() functions, only IMAP4.login(). I would still like to go back to imaplib._Authenticator.encode() function. The function is below. # inp = authobject(response) def encode(self, inp): oup = '' while inp: if len(inp) > 48: t = inp[:48] inp = inp[48:] else: t = inp inp = '' e = binascii.b2a_base64(t) if e: oup = oup + e[:-1] return oup binascii.b2a_base64() takes bytes, so inp must therefore be bytes, and returns bytes (Python 3). Then str + bytes (out + e[:-1]) fails. The fix would then be changing oup = oup + e[:-1] to oup = oup + e[:-1].decode() -- ___ Python tracker <http://bugs.python.org/issue13700> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13700] imaplib.IMAP4.authenticate authobject fails with PLAIN mechanism
Erno Tukia added the comment: I tried to fix the problem and the correct fix is to change oup = '' to oup = b'' in imaplib._Authenticator.encode() function, and not what I suggested in my previous post. After changing that PLAIN authentication works. -- ___ Python tracker <http://bugs.python.org/issue13700> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13700] imaplib.IMAP4.authenticate authobject fails with PLAIN mechanism
Erno Tukia added the comment: Here's a patch with test. I am not an IMAP guru, so please verify my patch. -- keywords: +patch Added file: http://bugs.python.org/file24132/issue13700.patch ___ Python tracker <http://bugs.python.org/issue13700> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13700] imaplib.IMAP4.authenticate authobject fails with PLAIN mechanism
Erno Tukia added the comment: Here's another patch that should fix the CRAM-MD5 authentication. My previous patch is required with this one. The patch includes a test. -- Added file: http://bugs.python.org/file24134/cram_md5.patch ___ Python tracker <http://bugs.python.org/issue13700> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13725] regrtest does not recognize -d flag
New submission from Erno Tukia : ./python -m test --help -d/--debug -- print traceback for failed tests ./python -m test -d test_imaplib option -d not recognized Use --help for usage Patch included. -- components: Tests files: regrtest-debug.patch keywords: patch messages: 150790 nosy: etukia priority: normal severity: normal status: open title: regrtest does not recognize -d flag type: behavior versions: Python 3.2, Python 3.3 Added file: http://bugs.python.org/file24159/regrtest-debug.patch ___ Python tracker <http://bugs.python.org/issue13725> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13726] regrtest ambiguous -S flag
New submission from Erno Tukia : ./python -m test --help -S/--slow -- print the slowest 10 tests -S is used to continue running tests after an aborted run. It will maintain the order a standard run (ie, this assumes -r is not used). This is useful after the tests have prematurely stopped for some external reason and you want to start running from where you left off rather than starting from the beginning. in Lib/test/regrtest.py opts, args = getopt.getopt(sys.argv[1:], '...S...', [..., 'slow', ... , 'start=', ...]) for o, a in opts: elif o in ('-S', '--start'): start = a elif o in ('-S', '--slow'): print_slow = True At the moment -S (no args) and --slow (no args) are the same, not what the documentation says and not how the code executes (-S goes with --start). Help says nothing about --start. --slow or --start needs a new short opt, and corrected documentation. -- assignee: docs@python components: Documentation, Tests messages: 150792 nosy: docs@python, etukia priority: normal severity: normal status: open title: regrtest ambiguous -S flag type: behavior versions: Python 3.2, Python 3.3 ___ Python tracker <http://bugs.python.org/issue13726> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13725] regrtest does not recognize -d flag
Erno Tukia added the comment: @Éric I just tried to fix, with tests, the imaplib bug (#13700) and I found this bug. And fixing this bug I happened to notice in the source code another bug (#13726). No problems with CPython test suite relating to these regrtest bugs. -- ___ Python tracker <http://bugs.python.org/issue13725> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13726] regrtest ambiguous -S flag
Erno Tukia added the comment: --start requires an argument but short opt -S does not. in Lib/test/regrtest.py opts, args = getopt.getopt(sys.argv[1:], '...S...', [..., 'start=', ...]) Patch included. -- keywords: +patch Added file: http://bugs.python.org/file24236/issue13726-2.patch ___ Python tracker <http://bugs.python.org/issue13726> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13726] regrtest ambiguous -S flag
Changes by Erno Tukia : -- resolution: fixed -> status: closed -> open ___ Python tracker <http://bugs.python.org/issue13726> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13725] regrtest does not recognize -d flag
Erno Tukia added the comment: Meador, thanks for the acknowledgement. -- ___ Python tracker <http://bugs.python.org/issue13725> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13700] imaplib.IMAP4.authenticate authobject does not work correctly in python3
Erno Tukia added the comment: Here's the updated patch. Tests now works. PLAIN works for me, that's only I can test against live system. test_login_cram_md5 test had extra \r\n in _send_tagged. diff imaplib_authenticate.patch imaplib_authenticate_v2.patch < + self._send_tagged(tag, 'OK', 'CRAM-MD5 successful\r\n') --- > + self._send_tagged(tag, 'OK', 'CRAM-MD5 successful') -- Added file: http://bugs.python.org/file26227/imaplib_authenticate_v2.patch ___ Python tracker <http://bugs.python.org/issue13700> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com