1import sys
2
3try:
4    # Our match_hostname function is the same as 3.5's, so we only want to
5    # import the match_hostname function if it's at least that good.
6    if sys.version_info < (3, 5):
7        raise ImportError("Fallback to vendored code")
8
9    from ssl import CertificateError, match_hostname
10except ImportError:
11    try:
12        # Backport of the function from a pypi module
13        from backports.ssl_match_hostname import CertificateError, match_hostname
14    except ImportError:
15        # Our vendored copy
16        from ._implementation import CertificateError, match_hostname
17
18# Not needed, but documenting what we provide.
19__all__ = ('CertificateError', 'match_hostname')
20