Skip to content
Myr

Refactoring in |raise_for_status| method.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- Simplified the if statements. - Remove duplicate code.

authored by Berker Peksag · committed by Berker Peksag · parent 54842cd · Browse files · 1 file+10 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−12 removed

  • other:+10 added−12 removed

1 file+10 added−12 removed

modified:requests/models.py+10 added-12 removed
825 unmodified lines
826827 if self.error:828 raise self.error829830 if (self.status_code >= 300) and (self.status_code < 400) and not allow_redirects:831 http_error = HTTPError('%s Redirection: %s' % (self.status_code, self.reason))832 http_error.response = self833 raise http_error830 if 300 <= self.status_code < 400 and not allow_redirects:831 http_error_msg = '%s Redirection: %s' % (self.status_code, self.reason)832835 elif (self.status_code >= 400) and (self.status_code < 500):836 http_error = HTTPError('%s Client Error: %s' % (self.status_code, self.reason))837 http_error.response = self838 raise http_error833 elif 400 <= self.status_code < 500:834 http_error_msg = '%s Client Error: %s' % (self.status_code, self.reason)835836 elif 500 <= self.status_code < 600:837 http_error_msg = '%s Server Error: %s' % (self.status_code, self.reason)840 elif (self.status_code >= 500) and (self.status_code < 600):841 http_error = HTTPError('%s Server Error: %s' % (self.status_code, self.reason))842 http_error.response = self843 raise http_error838839 http_error = HTTPError(http_error_msg)840 http_error.response = self841 raise http_error