Don't rethrow RequestException as IOError

Since RequestException already is an IOError, nothing of value is lost.
This commit is contained in:
Tobias Gruetzmacher 2020-09-28 12:05:01 +02:00
parent 8d7fd8b884
commit e34a0b539c

View file

@ -15,8 +15,6 @@ from urllib.parse import (parse_qs, quote as url_quote, unquote as url_unquote,
urlparse, urlunparse, urlsplit) urlparse, urlunparse, urlsplit)
from urllib.robotparser import RobotFileParser from urllib.robotparser import RobotFileParser
import requests
from .output import out from .output import out
from .configuration import UserAgent, App, SupportUrl from .configuration import UserAgent, App, SupportUrl
from . import AppName from . import AppName
@ -244,16 +242,12 @@ def urlopen(url, session, referrer=None, max_content_bytes=None,
else: else:
method = 'POST' method = 'POST'
out.debug(u'Sending POST data %s' % kwargs['data'], level=3) out.debug(u'Sending POST data %s' % kwargs['data'], level=3)
try:
req = session.request(method, url, **kwargs) req = session.request(method, url, **kwargs)
out.debug(u'Response cookies: %s' % req.cookies) out.debug(u'Response cookies: %s' % req.cookies)
check_content_size(url, req.headers, max_content_bytes) check_content_size(url, req.headers, max_content_bytes)
if req.status_code not in allow_errors: if req.status_code not in allow_errors:
req.raise_for_status() req.raise_for_status()
return req return req
except requests.exceptions.RequestException as err:
msg = 'URL retrieval of %s failed: %s' % (url, err)
raise IOError(msg)
def check_content_size(url, headers, max_content_bytes): def check_content_size(url, headers, max_content_bytes):