[Python-checkins] CVS: python/dist/src/Lib httplib.py,1.24,1.25

Guido van Rossum python-dev@python.org
Mon, 11 Dec 2000 12:32:23 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv12882

Modified Files:
	httplib.py 
Log Message:
Hoepeful fix for SF bug #123924: Windows - using OpenSSL, problem with
socket in httplib.py.

The bug reports that on Windows, you must pass sock._sock to the
socket.ssl() call.  But on Unix, you must pass sock itself.  (sock is
a wrapper on Windows but not on Unix; the ssl() call wants the real
socket object, not the wrapper.)

So we see if sock has an _sock attribute and if so, extract it.

Unfortunately, the submitter of the bug didn't confirm that this patch
works, so I'll just have to believe it (can't test it myself since I
don't have OpenSSL on Windows set up, and that's a nontrivial thing I
believe).


Index: httplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** httplib.py	2000/10/12 19:58:36	1.24
--- httplib.py	2000/12/11 20:32:20	1.25
***************
*** 614,618 ****
          sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          sock.connect((self.host, self.port))
!         ssl = socket.ssl(sock, self.key_file, self.cert_file)
          self.sock = FakeSocket(sock, ssl)
  
--- 614,621 ----
          sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          sock.connect((self.host, self.port))
!         realsock = sock
!         if hasattr(sock, "_sock"):
!             realsock = sock._sock
!         ssl = socket.ssl(realsock, self.key_file, self.cert_file)
          self.sock = FakeSocket(sock, ssl)