[MERGE][1.9][bug 293054] Build the ssl socket in a python-2.6 compatible way *and* make the test suite passes again on OSX with python-2.6

John Arbash Meinel john at arbash-meinel.com
Thu Nov 6 17:44:03 GMT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vincent Ladeuil wrote:
> So python-2.6 broke the compatibility with 2.5 regarding ssl sockets.
> 
> The fact that we need to work-around the lack of support for
> connecting to a proxy made that more apparent (I think that
> regular users of httplib/urllib2 are immune).
> 
> More problematic is the fact that our test suite didn't caught that.
> 
> This is because we lack an https server for which
> lp:~vila/bzr/bzr-https-server needed some love.
> 
> It still needs more love to be merged but at the least the
> associated patch which fix the problem could be extracted.
> 
> Things having evolved though, not everything (including the test
> server) can be submitted right now (but roughly speaking the test
> suite is mostly running in that branch including exercising
> existing http tests against a true https server (and for both
> pycurl and urllib).
> 
> Back to that patch, I also fixed some issues discovered while
> running the test suite with python-2.6 under Leopard (OSX 10.5),
> my previous tests were on OSX-10.4/python-2.5.
> 
> Since python-2.6 seems to be spreading, and this patch fixes
> three minor problems while being low risk, I'd like it to be
> included in 1.9final.
> 
> Thanks in advance,
> 
>        Vincent
> 
> 


+    def _dont_SIGQUIT_on_darwin(self):
^- Could we use SIGINT instead of SIGQUIT?


=== modified file 'bzrlib/tests/http_server.py'
- --- bzrlib/tests/http_server.py	2008-09-26 15:28:29 +0000
+++ bzrlib/tests/http_server.py	2008-11-06 14:34:00 +0000
@@ -347,7 +347,12 @@
              # WSAENOTCONN (10057) 'Socket is not connected' is harmless on
              # windows (occurs before the first connection attempt
              # vila--20071230)
- -             if not len(e.args) or e.args[0] != 10057:
+
+             # 'Socket is not connected' can also occur on OSX, with a
+             # "regular" ENOTCONN (when something went wrong during
test case
+             # setup leading to self.setUp() *not* being called but
+             # self.tearDown() still being called -- vila20081106
+             if not len(e.args) or e.args[0] not in (errno.ENOTCONN,
10057):
                  raise


So I did a check and on my python2.5 win32 install:

$ py -c "import errno; print errno.ENOTCONN"
10057

So it seems like doing:

if not len(e.args) or e.args[0] != errno.ENOTCONN:
  raise

is a better way to do it anyway.

...

- -# FIXME: Should test for ssl availability
+# Build the appropriate socket wrapper for ssl
+try:
+    import ssl # python 2.6
+    _ssl_wrap_socket = ssl.wrap_socket
+except ImportError:
+    def _ssl_wrap_socket(sock, key_file, cert_file):
+        ssl_sock = socket.ssl(sock, key_file, cert_file)
+        return httplib.FakeSocket(sock, ssl_sock)
+
+
^- Can you add a comment like:
  # python 2.4/2.5 don't have ssl and ssl.wrap_socket
  # instead they use httplib.FakeSocket


BB:tweak

I would also like to see this land in 1.9, but that is ultimately up to
Martin.

I would recommend opening a bug, targeted at 1.9final and marked
Critical, and attach a patch. Because I think it will help prevent this
from getting lost.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkTLOMACgkQJdeBCYSNAAOW2QCfbeRgHrVKEauHnbTnPrY/BUlg
ao4An0rtF5flOWven00VOnbN5W6qdsg9
=uR2n
-----END PGP SIGNATURE-----



More information about the bazaar mailing list