This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: socket.ssl fails when passed a _socketobj
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doko, loewis
Priority: high Keywords:

Created on 2003-06-14 10:19 by doko, last changed 2022-04-10 16:09 by admin. This issue is now closed.

Messages (2)
msg16383 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2003-06-14 10:19
[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. 

msg16384 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-06-14 13:31
Logged In: YES 
user_id=21627

This is fixed in

httplib.py 1.77
socket.py 1.42
History
Date User Action Args
2022-04-10 16:09:12adminsetgithub: 38647
2003-06-14 10:19:54dokocreate