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 Stephen.Evans
Recipients Stephen.Evans, barry, r.david.murray
Date 2016-03-11.23:23:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1457738623.54.0.0867122071018.issue26543@psf.upfronthosting.co.za>
In-reply-to
Content
With the imaplib.Debug=3 (or greater) imaplib.noop() will crash if there are any untagged responses present.

The _dump_ur() function has not been converted to expect bytes in the lambda variable x[1]. An abbreviate example of the 'dict' parameter would be:

{'READ-WRITE': [b''], 'FETCH': [b'1 (FLAGS (\\Recent NonJunk))']}

This _dump_ur() function needs converting to Python 3.x, say, change the map/lambda line to:
  l = map(lambda x:'%s: %r' % (x[0], x[1]), l)


A sample crash inducing session produced by the attached file (using another email client to produce untagged responses for NOOP):

  20:01.23 imaplib version 2.58
  20:01.23 new IMAP4 connection, tag=b'LMHB'
  20:01.48 CAPABILITIES: ('IMAP4REV1', 'LITERAL+', 'SASL-IR', 'LOGIN-REFERRALS', 'ID', 'ENABLE', 'IDLE', 'NAMESPACE', 'AUTH=PLAIN', 'AUTH=LOGIN')
Traceback (most recent call last):
  File "E:/temp/imap-idle/imaplib-noop.py", line 18, in <module>
    connection.noop()  # Crashes here.
  File "C:\Python35\lib\imaplib.py", line 656, in noop
    self._dump_ur(self.untagged_responses)
  File "C:\Python35\lib\imaplib.py", line 1210, in _dump_ur
    self._mesg('untagged responses dump:%s%s' % (t, t.join(l)))
  File "C:\Python35\lib\imaplib.py", line 1209, in <lambda>
    l = map(lambda x:'%s: "%s"' % (x[0], x[1][0] and '" "'.join(x[1]) or ''), l)
TypeError: sequence item 0: expected str instance, bytes found
History
Date User Action Args
2016-03-11 23:23:43Stephen.Evanssetrecipients: + Stephen.Evans, barry, r.david.murray
2016-03-11 23:23:43Stephen.Evanssetmessageid: <1457738623.54.0.0867122071018.issue26543@psf.upfronthosting.co.za>
2016-03-11 23:23:43Stephen.Evanslinkissue26543 messages
2016-03-11 23:23:43Stephen.Evanscreate