On Apr 5, 12:09 am, Steven D'Aprano <steve +comp.lang.pyt...@pearwood.info> wrote: > On Wed, 04 Apr 2012 22:13:55 -0700, Steve Howell wrote: > > On Apr 4, 9:49 pm, Steven D'Aprano <steve > > +comp.lang.pyt...@pearwood.info> wrote: > >> I can connect to an IMAP server using Python 2.6: > > >> steve@runes:~$ python2.6 > >> Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2 > >> Type "help", "copyright", "credits" or "license" for more > >> information.>>> import imaplib > >> >>> server = imaplib.IMAP4_SSL('xxxxx') > >> >>> print server > > >> <imaplib.IMAP4_SSL instance at 0xb7183c4c> > > >> But when I try with Python 3.2, it just sits there until it times out: > > >> steve@runes:~$ python3.2 > >> Python 3.2.2 (default, Feb 29 2012, 18:11:33) [GCC 4.4.5] on linux2 > >> Type "help", "copyright", "credits" or "license" for more > >> information.>>> import imaplib > >> >>> server = imaplib.IMAP4('xxxxx', imaplib.IMAP4_SSL_PORT) > > >> Traceback (most recent call last): > >> [...] > >> socket.timeout: timed out > > >> What am I doing wrong? > > > Is it simply the wrong port? (IMAP4_SSL_PORT vs. IMAP4_PORT) > > No, it is the correct port, 993. > > > How long do you wait before seeing the timeout? > > Indefinitely. > > > Have you tried print-debugging within your local copy of imaplib.py? The > > code related to making the connection just wraps > > socket.create_connection: > > I'm not going to start debugging the standard library until after I'm > satisfied that I'm not doing something wrong. >
I'm not suggesting that you debug the standard library because I think the library itself is broken. I'm suggesting that using the source code that's freely available to you can help you have some insight on what's going wrong. Do you have a working theory on what you're doing wrong? You've already ruled out the port. Why are you changing the invocation between versions of Python? imaplib.IMAP4_SSL('xxxxx') # 2.6 imaplib.IMAP4('xxxxx', imaplib.IMAP4_SSL_PORT) # 3.2 I'm sure the standard library works fine, and you're just doing something silly, like mistyping the host name or forgetting to start the server. Maybe you're running 3.2 in a slightly different OS environment? The ONE thing that you can find out almost immediately is what self.host and self.post are set to when _create_socket gets called. You could almost immediately narrow down the problem to socket.create_connection() instead of IMAP. -- http://mail.python.org/mailman/listinfo/python-list