From 086e19d8e175cccb630ee3589affdd2f38075ecd Mon Sep 17 00:00:00 2001 From: Hosam Aly Date: Sat, 3 Oct 2015 16:34:36 +0100 Subject: [PATCH] Clarify the contract of Response#ok, and avoid exceptions in it --- requests/models.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/requests/models.py b/requests/models.py index 6d6265d0..a822dd15 100644 --- a/requests/models.py +++ b/requests/models.py @@ -616,11 +616,8 @@ class Response(object): @property def ok(self): - try: - self.raise_for_status() - except HTTPError: - return False - return True + """True if the status code does *not* indicate an error, i.e. status code < 400.""" + return self.status_code < 400 @property def is_redirect(self):