SIGN IN SIGN UP

Fix API break when contents not found (#3181)

Alternative to https://github.com/PyGithub/PyGithub/pull/3180 that fixes
https://github.com/PyGithub/PyGithub/issues/3179, but tries to preserve
existing behavior.

UnknownObjectException is raised for all kinds of calls that may return
a 404, for example
[get_repo](https://pygithub.readthedocs.io/en/stable/github_objects/Organization.html#github.Organization.Organization.get_repo).
Those API calls still return a "Not Found" message:

```python
>>> from github import Github
>>> from os import environ
>>> Github(environ['GITHUB_TOKEN']).get_organization('asdfqwertyjkl')
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    Github(environ['GITHUB_TOKEN']).get_organization('asdfqwertyjkl')
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.13/site-packages/github/MainClass.py", line 408, in get_organization
    headers, data = self.__requester.requestJsonAndCheck("GET", f"/orgs/{login}")
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.13/site-packages/github/Requester.py", line 586, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.13/site-packages/github/Requester.py", line 744, in __check
    raise self.createException(status, responseHeaders, data)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/orgs/orgs#get-an-organization", "status": "404"}
```

So, in this PR we honor both kinds of messages, but still no _other_
kinds of messages.

Tests are updated to reflect the new case.
T
Timothy Klopotoski committed
d90323fac7e6004b097dd91f09668f285ce3f4d0
Parent: 67cfdb2
Committed by GitHub <noreply@github.com> on 1/30/2025, 8:53:10 PM