This change is to fix an issue with HTTP requests returning 404 for some URLs, despite the URL functioning as expected in browsers, curl, wget, etc. Only affects Python versions earlier than 3.10.
Bug Description:
When using a Python version earlier than 3.10, some HTTP requests return 404 through the urllib.request.urlopen function. This seems to be happening most often with Wordpress CDN urls. Some examples:
These urls work as expected in the browser, but fail with the aforementioned function.
Fix:
Adding a default context and setting the ALPN protocol seems to resolve the issue. The change should be pretty safe as it's the same change in Python 3.10+.
This change is to fix an issue with HTTP requests returning 404 for some URLs, despite the URL functioning as expected in browsers, curl, wget, etc. Only affects Python versions earlier than 3.10.
Bug Description: When using a Python version earlier than 3.10, some HTTP requests return 404 through the
urllib.request.urlopen
function. This seems to be happening most often with Wordpress CDN urls. Some examples:These urls work as expected in the browser, but fail with the aforementioned function.
Fix: Adding a default context and setting the ALPN protocol seems to resolve the issue. The change should be pretty safe as it's the same change in Python 3.10+.
Discussion: https://bugs.python.org/issue40968 Source: https://github.com/python/cpython/commit/f97406be4c0a02c1501c7ab8bc8ef3850eddb962