Re: [Python-Dev] r86514 - in python/branches/py3k/Lib: test/test_xmlrpc.py xmlrpc/client.py
On Thu, 18 Nov 2010 16:00:53 +0100 (CET) senthil.kumaran python-check...@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 test_ssl_presence(self): +#Check for ssl support +have_ssl = False +if hasattr(socket, 'ssl'): +have_ssl = 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:').bad_function() +except: +exc = sys.exc_info() +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. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] r86514 - in python/branches/py3k/Lib: test/test_xmlrpc.py xmlrpc/client.py
On Thu, Nov 18, 2010 at 11:18 PM, Antoine Pitrou solip...@pitrou.net wrote: Log: Fix Issue 9991: xmlrpc client ssl check faulty [...] + def test_ssl_presence(self): + #Check for ssl support + have_ssl = False + if hasattr(socket, 'ssl'): + have_ssl = 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. The history of the bug report showed that it was closed earlier with comments such as Python should be complied with SSL which had resulted in some confusion, so after some thought, I let those earlier verifications remain (Just for readability/understanding the context of the tests). Thinking again, I see that it is not required. Agree to your comments on code changes. Shall change it. -- Senthil ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com