File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -555,25 +555,27 @@ def _raise_for_5xx(self, response):
555555 :param response: HTTP response object from requests
556556 Raises :class:`requests.exceptions.HTTPError`, if a 5XX error occurred.
557557 """
558- http_error_msg = ''
558+ http_error_msg = ""
559559 if isinstance (response .reason , bytes ):
560560 # We attempt to decode utf-8 first because some servers
561561 # choose to localize their reason strings. If the string
562562 # isn't utf-8, we fall back to iso-8859-1 for all other
563563 # encodings. (See psf/requests PR #3538)
564564 try :
565- reason = response .reason .decode (' utf-8' )
565+ reason = response .reason .decode (" utf-8" )
566566 except UnicodeDecodeError :
567- reason = response .reason .decode (' iso-8859-1' )
567+ reason = response .reason .decode (" iso-8859-1" )
568568 else :
569569 reason = response .reason
570570
571571 if 400 <= response .status_code < 500 :
572572 pass # ignored
573573
574574 elif 500 <= response .status_code < 600 :
575- http_error_msg = u'%s Server Error: %s for url: %s' % (
576- response .status_code , reason , response .url
575+ http_error_msg = "%s Server Error: %s for url: %s" % (
576+ response .status_code ,
577+ reason ,
578+ response .url ,
577579 )
578580
579581 if http_error_msg :
Original file line number Diff line number Diff line change @@ -543,7 +543,7 @@ def test_raise_for_5xx(self):
543543 fake_resp = mock .MagicMock ()
544544 fake_resp .status_code = 504
545545 fake_resp .reason = reason_bytes
546- reason_unicode = "¡An error occurred!"
546+ reason_unicode = "\u00A1 An error occurred!"
547547 fake_resp .url = "https://example.com/token"
548548 expected = (
549549 "504 Server Error: " + reason_unicode + " for url: " + fake_resp .url
You can’t perform that action at this time.
0 commit comments