[Python-Dev] r86514 - in python/branches/py3k/Lib: test/test_xmlrpc.py xmlrpc/client.py (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Thu Nov 18 16🔞57 CET 2010


On Thu, 18 Nov 2010 16:00:53 +0100 (CET) senthil.kumaran <python-checkins at python.org> wrote:

Author: senthil.kumaran Date: Thu Nov 18 16:00:53 2010 New Revision: 86514

Log: Fix Issue 9991: xmlrpc client ssl check faulty [...] + def testsslpresence(self): + #Check for ssl support + havessl = False + if hasattr(socket, 'ssl'): + havessl = True

This is not the right way to check for ssl. socket.ssl is deprecated in 2.x and doesn't exist in 3.x. "import ssl" is enough.

+ try: + xmlrpc.client.ServerProxy('https://localhost:9999').badfunction() + except: + exc = sys.excinfo() + if exc[0] == socket.error:

This is a rather clumsy way to check for exception types. Why don't you just write "except socket.error"?

- if not hasattr(socket, "ssl"): + if not hasattr(http.client, "ssl"):

That isn't better. "http.client.ssl" is not a public API. You should check for http.client.HTTPSConnection instead.

cheers

Antoine.



More information about the Python-Dev mailing list