[Python-bugs-list] [ python-Bugs-754447 ] socket.ssl fails when passed a _socketobj

SourceForge.net noreply@sourceforge.net
Sat, 14 Jun 2003 03:19:54 -0700


Bugs item #754447, was opened at 2003-06-14 10:19
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=754447&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Matthias Klose (doko)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket.ssl fails when passed a _socketobj

Initial Comment:
[forwarded from http://bugs.debian.org/196082]

rechecked with 2.3 CVS 20030614

When trying to create a IMAP connection over SSL I'm
getting a failiure
with python2.3. You can recreate it with the following
simple script:

#!/usr/bin/python2.3

import imaplib
c = imaplib.IMAP4_SSL("localhost")

which dies with the following trace:
Traceback (most recent call last):
  File "./sslimaptest.py", line 4, in ?
    c = imaplib.IMAP4_SSL("localhost")
  File
"/home/andyh/projects/personal/webimap/imaplib.py",
line 1040, in __init__
    IMAP4.__init__(self, host, port)
  File
"/home/andyh/projects/personal/webimap/imaplib.py",
line 151, in __init__
    self.open(host, port)
  File
"/home/andyh/projects/personal/webimap/imaplib.py",
line 1053, in open
    self.sslobj = socket.ssl(self.sock, self.keyfile,
self.certfile)
TypeError: ssl() argument 1 must be _socket.socket, not
_socketobject


I simplified the code IMAP4_SSL calls to the following:
#!/usr/bin/python2.3

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 993))
socket.ssl(sock, None, None)

which dies:
Traceback (most recent call last):
  File "./ssltest.py", line 7, in ?
    socket.ssl(sock, None, None)
TypeError: ssl() argument 1 must be _socket.socket, not
_socketobject

It appears that the socket.ssl() function doesn't like
taking the objects
the socket library is producing!

I noticed in the python2.3 changelog the following entry:
- The socket module now always uses the _socketobject
wrapper class, even 
on platforms which have dup(2). The makefile() method
is built directly on 
uop of the socket without duplicating the file
descriptor, allowing timeouts 
to work properly.

Not sure if its relevant. 



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=754447&group_id=5470