bugs
in imaplib.py change
data = self.sslobj.read(size-read)
to
data = self.sslobj.read(min(size-read, 16384))