File tree 2 files changed +8
-6
lines changed
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):
555
555
:param response: HTTP response object from requests
556
556
Raises :class:`requests.exceptions.HTTPError`, if a 5XX error occurred.
557
557
"""
558
- http_error_msg = ''
558
+ http_error_msg = ""
559
559
if isinstance (response .reason , bytes ):
560
560
# We attempt to decode utf-8 first because some servers
561
561
# choose to localize their reason strings. If the string
562
562
# isn't utf-8, we fall back to iso-8859-1 for all other
563
563
# encodings. (See psf/requests PR #3538)
564
564
try :
565
- reason = response .reason .decode (' utf-8' )
565
+ reason = response .reason .decode (" utf-8" )
566
566
except UnicodeDecodeError :
567
- reason = response .reason .decode (' iso-8859-1' )
567
+ reason = response .reason .decode (" iso-8859-1" )
568
568
else :
569
569
reason = response .reason
570
570
571
571
if 400 <= response .status_code < 500 :
572
572
pass # ignored
573
573
574
574
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 ,
577
579
)
578
580
579
581
if http_error_msg :
Original file line number Diff line number Diff line change @@ -543,7 +543,7 @@ def test_raise_for_5xx(self):
543
543
fake_resp = mock .MagicMock ()
544
544
fake_resp .status_code = 504
545
545
fake_resp .reason = reason_bytes
546
- reason_unicode = "¡An error occurred!"
546
+ reason_unicode = "\u00A1 An error occurred!"
547
547
fake_resp .url = "https://example.com/token"
548
548
expected = (
549
549
"504 Server Error: " + reason_unicode + " for url: " + fake_resp .url
You can’t perform that action at this time.
0 commit comments