Skip to content

Commit

Permalink
[1.26] Combine UnicodeError and ValueError branches in ssl_match_host…
Browse files Browse the repository at this point in the history
…name for coverage
  • Loading branch information
hramezani committed Jan 24, 2022
1 parent a4539fb commit 048c0ba
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/urllib3/util/ssl_match_hostname.py
Expand Up @@ -112,11 +112,9 @@ def match_hostname(cert, hostname):
try:
# Divergence from upstream: ipaddress can't handle byte str
host_ip = ipaddress.ip_address(_to_unicode(hostname))
except ValueError:
# Not an IP address (common case)
host_ip = None
except UnicodeError:
# Divergence from upstream: Have to deal with ipaddress not taking
except (UnicodeError, ValueError):
# ValueError: Not an IP address (common case)
# UnicodeError: Divergence from upstream: Have to deal with ipaddress not taking
# byte strings. addresses should be all ascii, so we consider it not
# an ipaddress in this case
host_ip = None
Expand Down

0 comments on commit 048c0ba

Please sign in to comment.