linkcheck: Remove call to is_ssl_error()

This method always returns False, it is dead code. The exception
checking stopped working because Requests library wraps SSL errors in a
`requests.exceptions.SSLError` and no longer throws an
`urllib3.exceptions.SSLError`. The first argument to that exception is
an `urllib3.exceptions.MaxRetryError`.
This commit is contained in:
François Freitag 2020-11-10 21:06:59 +01:00
parent 040a1e7743
commit 683635f5b4
4 changed files with 12 additions and 5 deletions

View File

@ -13,6 +13,7 @@ Incompatible changes
Deprecated
----------
* The ``is_ssl_error()`` function of ``sphinx.util.requests``
* The ``follow_wrapped`` argument of ``sphinx.util.inspect.signature()``
Features added

View File

@ -27,6 +27,11 @@ The following is a list of deprecated interfaces.
- Alternatives
* - ``sphinx.util.requests.is_ssl_error()``
- 3.4
- 5.0
- N/A
* - The ``follow_wrapped`` argument of ``sphinx.util.inspect.signature()``
- 3.4
- 5.0

View File

@ -28,7 +28,6 @@ from sphinx.locale import __
from sphinx.util import encode_uri, logging, requests
from sphinx.util.console import darkgray, darkgreen, purple, red, turquoise # type: ignore
from sphinx.util.nodes import get_node_line
from sphinx.util.requests import is_ssl_error
logger = logging.getLogger(__name__)
@ -189,10 +188,7 @@ class CheckExternalLinksBuilder(Builder):
else:
return 'broken', str(err), 0
except Exception as err:
if is_ssl_error(err):
return 'ignored', str(err), 0
else:
return 'broken', str(err), 0
return 'broken', str(err), 0
if response.url.rstrip('/') == req_url.rstrip('/'):
return 'working', '', 0
else:

View File

@ -18,6 +18,7 @@ import requests
import sphinx
from sphinx.config import Config
from sphinx.deprecation import RemovedInSphinx50Warning
try:
from requests.packages.urllib3.exceptions import SSLError
@ -43,6 +44,10 @@ useragent_header = [('User-Agent',
def is_ssl_error(exc: Exception) -> bool:
"""Check an exception is SSLError."""
warnings.warn(
"is_ssl_error() is outdated and likely returns incorrect results "
"for modern versions of Requests.",
RemovedInSphinx50Warning)
if isinstance(exc, SSLError):
return True
else: