diff --git a/github/GithubException.py b/github/GithubException.py index 869c83d7..02e7a75e 100644 --- a/github/GithubException.py +++ b/github/GithubException.py @@ -77,9 +77,3 @@ class RateLimitExceededException(GithubException): """ Exception raised when the rate limit is exceeded (when Github API replies with a 403 rate limit exceeded HTML status) """ - - -class NotModifiedException(GithubException): - """ - Exception raised when conditional request is made to a resoure that has not changed - """ diff --git a/github/GithubObject.py b/github/GithubObject.py index 92efb7f2..6bc5a7bb 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -55,20 +55,20 @@ class GithubObject(object): def __init__(self, requester, headers, attributes, completed): self._requester = requester - # Make sure headers are signed before any operations on attributes - # Object creatation requires headers as parameter - self._headers = headers self._initAttributes() - self._storeAndUseAttributes(attributes) + self._storeAndUseAttributes(headers, attributes) # Ask requester to do some checking, for debug and test purpose # Since it's most handy to access and kinda all-knowing if self.CHECK_AFTER_INIT_FLAG: requester.check_me(self) - def _storeAndUseAttributes(self, attributes): - self._useAttributes(attributes) + def _storeAndUseAttributes(self, headers, attributes): + # Make sure headers are assigned before calling _useAttributes + # (Some derived classes will use headers in _useAttributes) + self._headers = headers self._rawData = attributes + self._useAttributes(attributes) @property def raw_data(self): @@ -144,18 +144,19 @@ class GithubObject(object): if self.last_modified is not None: conditionalRequestHeader[Consts.REQ_IF_MODIFIED_SINCE] = self.last_modified - try: - headers, data = self._requester.requestJsonAndCheck( - "GET", - self._url, - conditionalRequestHeader, - None - ) - self._storeAndUseAttributes(data) + status, responseHeaders, output = self._requester.requestJson( + "GET", + self._url, + conditionalRequestHeader, + None + ) + if status == 304: + return False + else: + headers, data = self._requester._Requester__check(status, responseHeaders, output) + self._storeAndUseAttributes(headers, data) self.__completed = True return True - except GithubException.NotModifiedException: # #193: Why raise and catch? Can't we just check? - return False class NonCompletableGithubObject(GithubObject): @@ -183,6 +184,5 @@ class CompletableGithubObject(GithubObject): None, None ) - self._headers = headers - self._storeAndUseAttributes(data) + self._storeAndUseAttributes(headers, data) self.__completed = True diff --git a/github/Requester.py b/github/Requester.py index 9ac335e6..792861d9 100644 --- a/github/Requester.py +++ b/github/Requester.py @@ -179,8 +179,6 @@ class Requester: # Log frame self.DEBUG_ON_RESPONSE(status, responseHeaders, output) - if status == 304: - raise GithubException.NotModifiedException(status, output) if status >= 400: raise self.__createException(status, output) return responseHeaders, output