Patchwork hghave: change ssl check to just check ssl module

login
register
mail settings
Submitter Gregory Szorc
Date March 19, 2016, 8:57 p.m.
Message ID <0b718a963d65f1ed2e60.1458421049@gps-mbp.local>
Download mbox | patch
Permalink /patch/13962/
State Accepted
Headers show

Comments

Gregory Szorc - March 19, 2016, 8:57 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1458420660 25200
#      Sat Mar 19 13:51:00 2016 -0700
# Node ID 0b718a963d65f1ed2e609b8f38a129881a598217
# Parent  1f3d9fe592151d4eab21282e87628ef655c67daf
hghave: change ssl check to just check ssl module

Previously, the "ssl" check effectively looked for PyOpenSSL
or Python 2.7.9. After this patch, we simply look for just the
"ssl" module.

After d962e955da08, there have been no references to PyOpenSSL in
the tree (the previous usage of PyOpenSSL was to implement ssl
support on old, no longer supported Python versions that didn't
have an ssl module (e.g. Python 2.4). So, the check for PyOpenSSL
served no purpose.

Pythons we support ship with the ssl module. Although it may not be
available in all installations. So, we still need the check for
whether the ssl module imports, hence the hghave check.

The main side-effect of this change is that we now run test-https.t
(the only test requiring the "ssl" hghave feature) on Python <2.7.9
when PyOpenSSL is not installed (which is probably most installations)
and the ssl module is available. Before, we wouldn't run this test
on these older Python versions.

I confirmed that test-https.t passes with Python 2.6.9 and 2.7.8 on
OS X 10.11.
Augie Fackler - March 19, 2016, 11 p.m.
LGTM, queued thanks

> On Mar 19, 2016, at 13:57, Gregory Szorc <gregory.szorc@gmail.com> wrote:
> 
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1458420660 25200
> #      Sat Mar 19 13:51:00 2016 -0700
> # Node ID 0b718a963d65f1ed2e609b8f38a129881a598217
> # Parent  1f3d9fe592151d4eab21282e87628ef655c67daf
> hghave: change ssl check to just check ssl module
> 
> Previously, the "ssl" check effectively looked for PyOpenSSL
> or Python 2.7.9. After this patch, we simply look for just the
> "ssl" module.
> 
> After d962e955da08, there have been no references to PyOpenSSL in
> the tree (the previous usage of PyOpenSSL was to implement ssl
> support on old, no longer supported Python versions that didn't
> have an ssl module (e.g. Python 2.4). So, the check for PyOpenSSL
> served no purpose.
> 
> Pythons we support ship with the ssl module. Although it may not be
> available in all installations. So, we still need the check for
> whether the ssl module imports, hence the hghave check.
> 
> The main side-effect of this change is that we now run test-https.t
> (the only test requiring the "ssl" hghave feature) on Python <2.7.9
> when PyOpenSSL is not installed (which is probably most installations)
> and the ssl module is available. Before, we wouldn't run this test
> on these older Python versions.
> 
> I confirmed that test-https.t passes with Python 2.6.9 and 2.7.8 on
> OS X 10.11.
> 
> diff --git a/tests/hghave.py b/tests/hghave.py
> --- a/tests/hghave.py
> +++ b/tests/hghave.py
> @@ -340,17 +340,12 @@ def has_outer_repo():
>     # failing for other reasons than 'no repo' imply that there is a repo
>     return not matchoutput('hg root 2>&1',
>                            r'abort: no repository found', True)
> 
> -@check("ssl", ("(python >= 2.6 ssl module and python OpenSSL) "
> -               "OR python >= 2.7.9 ssl"))
> +@check("ssl", "ssl module available")
> def has_ssl():
>     try:
>         import ssl
> -        if getattr(ssl, 'create_default_context', False):
> -            return True
> -        import OpenSSL
> -        OpenSSL.SSL.Context
>         return True
>     except ImportError:
>         return False
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Pierre-Yves David - March 20, 2016, 12:43 a.m.
On 03/19/2016 04:00 PM, Augie Fackler wrote:
> LGTM, queued thanks

pyflakes send his regard. I added a random attribut access to fix that 
the unused ssl variable.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -340,17 +340,12 @@  def has_outer_repo():
     # failing for other reasons than 'no repo' imply that there is a repo
     return not matchoutput('hg root 2>&1',
                            r'abort: no repository found', True)
 
-@check("ssl", ("(python >= 2.6 ssl module and python OpenSSL) "
-               "OR python >= 2.7.9 ssl"))
+@check("ssl", "ssl module available")
 def has_ssl():
     try:
         import ssl
-        if getattr(ssl, 'create_default_context', False):
-            return True
-        import OpenSSL
-        OpenSSL.SSL.Context
         return True
     except ImportError:
         return False