Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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 ( # type: ignore 

14 CertificateError, 

15 match_hostname, 

16 ) 

17 except ImportError: 

18 # Our vendored copy 

19 from ._implementation import CertificateError, match_hostname # type: ignore 

20 

21# Not needed, but documenting what we provide. 

22__all__ = ("CertificateError", "match_hostname")