Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; "'',": 0.07; 'subject:version': 0.09; 'def': 0.12; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'open()': 0.16; 'port))': 0.16; 'self.file': 0.16; 'self.port': 0.16; 'self.sock': 0.16; 'self.sslobj': 0.16; 'subject:SSL': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'host': 0.29; "i'm": 0.30; 'work:': 0.31; 'skip:s 30': 0.35; 'but': 0.35; 'method': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'too': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'our': 0.64; 'received:50.22': 0.84; 'edwards': 0.91; 'dirty': 0.93 Date: Wed, 9 Apr 2014 15:33:11 -0500 From: Tim Chase To: python-list@python.org Subject: Re: imaplib: how to specify SSL/TLS protocol version? In-Reply-To: References: X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1397075591 news.xs4all.nl 2838 [2001:888:2000:d::a6]:59987 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69981 On 2014-04-09 20:20, Grant Edwards wrote: > I'm not too keen on this approach, but monkey-patching the open() > method seems to work: > > def my_imap4_ssl_open(self, host = '', port = 993): > self.host = host > self.port = port > self.sock = socket.create_connection((host, port)) > self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, > self.certfile, ssl_version=ssl.PROTOCOL_TLSv1) self.file = > self.sslobj.makefile('rb') > > imaplib.IMAP4_SSL.open = my_imap4_ssl_open Our messages passed in the ether. You don't have to feel dirty for monkey-patching, as you can just do it with inheritance. -tkc