Skip to content

Commit

Permalink
Merge pull request #5119 from alanyee/patch-1
Browse files Browse the repository at this point in the history
Update sessions.py
  • Loading branch information
kennethreitz committed Aug 20, 2019
2 parents d79024f + 9bc49b5 commit dd15e52
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions requests/sessions.py
Expand Up @@ -162,15 +162,15 @@ def resolve_redirects(self, resp, req, stream=False, timeout=None,
resp.raw.read(decode_content=False)

if len(resp.history) >= self.max_redirects:
raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects, response=resp)
raise TooManyRedirects('Exceeded {} redirects.'.format(self.max_redirects), response=resp)

# Release the connection back into the pool.
resp.close()

# Handle redirection without scheme (see: RFC 1808 Section 4)
if url.startswith('//'):
parsed_rurl = urlparse(resp.url)
url = '%s:%s' % (to_native_string(parsed_rurl.scheme), url)
url = ':'.join([to_native_string(parsed_rurl.scheme), url])

# Normalize url case and attach previous fragment if needed (RFC 7231 7.1.2)
parsed = urlparse(url)
Expand Down Expand Up @@ -728,7 +728,7 @@ def get_adapter(self, url):
return adapter

# Nothing matches :-/
raise InvalidSchema("No connection adapters were found for '%s'" % url)
raise InvalidSchema("No connection adapters were found for {!r}".format(url))

def close(self):
"""Closes all adapters and as such the session"""
Expand Down

0 comments on commit dd15e52

Please sign in to comment.