imaplib: how to specify SSL/TLS protocol version?

Chris Angelico rosuav at gmail.com
Wed Apr 9 21:55:23 EDT 2014


On Thu, Apr 10, 2014 at 7:10 AM, Grant Edwards <invalid at invalid.invalid> wrote:
> I left out a relevent fact: I'm not the one calling IMAP4_<whatever>.
>
> That's being done by the imapclient library.  There's no way to pass
> imapclient a custom class to use.  It's hard-waired to call either
> imaplib.IMAP4_stream(), imaplib.IMAP4(), or imaplib.IMAP4_SSL().  I
> could create an IMAP4_TLS1 class, but I would then have to sub-class
> imapclient.IMAPClient and override its _create_IMAP4() method to make
> it call my IMAP4_TLS1() class instead of calling imaplib.IMAP4_SSL().
>
> Monkey-patching imaplib seems a little better since it it doesn't
> depend on assumptions about the internal workings of imapclient (other
> than the fact that it uses imaplib.IMAP4_SSL).

That's an argument in favour of a minor case of serious
monkey-patching. Although if you do feel dirty, try to hold on to that
feeling because that is the proper reaction to being told that you're
monkey-patching.

ChrisA
okay, now I feel like a moron... not just a regular moron, though...



More information about the Python-list mailing list