gh-94199: Remove ssl.match_hostname() function by vstinner · Pull Request #94224 · python/cpython

Hum, it seems like this function deprecated since Python 3.7 is still widely used :-(

According to a code search on ssl.match_hostname, 37 projects of PyPI top 5000 projects use the deprecated function:

  • aliyun-python-sdk-core-2.13.36
  • ansible-core-2.13.1
  • backports.ssl_match_hostname-3.7.0.1
  • cassandra-driver-3.25.0
  • clvm_tools_rs-0.1.14
  • docker-5.0.3
  • docker-compose-1.29.2
  • docker-py-1.10.6
  • eth_abi-3.0.0
  • eth-account-0.6.1
  • eth-hash-0.3.2
  • eth-rlp-0.3.0
  • eth-utils-2.0.0
  • geventhttpclient-1.5.4
  • hexbytes-0.2.2
  • jedi-0.18.1
  • ldap3-2.9.1
  • newrelic-7.12.0.176
  • oci-2.72.0
  • pex-2.1.93
  • pip-22.1.2
  • pipenv-2022.6.7
  • pipreqs-0.4.11
  • pymongo-4.1.1
  • python-telegram-bot-13.12
  • pytype-2022.6.23
  • raven-6.10.0
  • rethinkdb-2.4.9
  • salt-3004.2
  • snowflake-connector-python-2.7.8
  • suds-1.1.1
  • suds-community-1.1.1
  • thrift-0.16.0
  • types-backports-0.1.3
  • types-urllib3-1.26.15
  • urllib3-1.26.9
  • xdis-6.0.4

I didn't check if the function is used on any Python version, or only on old Python versions, or maybe only on recent Python versions. The backports.ssl_match_hostname project is a backport of the ssl.match_hostname() function for Python 3.6 and older.

Searching for match_hostname finds 65 projects. For example, (distlib/compat.py)[https://github.com/pypa/distlib/blob/9b535c342eb7d11bed584e32e53f5d1c9303b034/distlib/compat.py#L92-L189] uses from ssl import match_hostname but has a fallback implementation for Python 3.6 and older.

The urllib3 module has its own implementation: urllib3/util/ssl_match_hostname.py.

cc @hugovk