Don't rethrow RequestException as IOError
Since RequestException already is an IOError, nothing of value is lost.
This commit is contained in:
parent
8d7fd8b884
commit
e34a0b539c
1 changed files with 6 additions and 12 deletions
|
@ -15,8 +15,6 @@ from urllib.parse import (parse_qs, quote as url_quote, unquote as url_unquote,
|
|||
urlparse, urlunparse, urlsplit)
|
||||
from urllib.robotparser import RobotFileParser
|
||||
|
||||
import requests
|
||||
|
||||
from .output import out
|
||||
from .configuration import UserAgent, App, SupportUrl
|
||||
from . import AppName
|
||||
|
@ -244,16 +242,12 @@ def urlopen(url, session, referrer=None, max_content_bytes=None,
|
|||
else:
|
||||
method = 'POST'
|
||||
out.debug(u'Sending POST data %s' % kwargs['data'], level=3)
|
||||
try:
|
||||
req = session.request(method, url, **kwargs)
|
||||
out.debug(u'Response cookies: %s' % req.cookies)
|
||||
check_content_size(url, req.headers, max_content_bytes)
|
||||
if req.status_code not in allow_errors:
|
||||
req.raise_for_status()
|
||||
return req
|
||||
except requests.exceptions.RequestException as err:
|
||||
msg = 'URL retrieval of %s failed: %s' % (url, err)
|
||||
raise IOError(msg)
|
||||
req = session.request(method, url, **kwargs)
|
||||
out.debug(u'Response cookies: %s' % req.cookies)
|
||||
check_content_size(url, req.headers, max_content_bytes)
|
||||
if req.status_code not in allow_errors:
|
||||
req.raise_for_status()
|
||||
return req
|
||||
|
||||
|
||||
def check_content_size(url, headers, max_content_bytes):
|
||||
|
|
Loading…
Reference in a new issue