Repository: datalad/datalad

Issue:
Incompatible with PyGithub v1.55
```
======================================================================
ERROR: datalad.support.tests.test_github_.test__make_github_repos
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/dl-miniconda-z1552950/lib/python3.8/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/tmp/dl-miniconda-z1552950/lib/python3.8/site-packages/datalad/support/tests/test_github_.py", line 110, in test__make_github_repos
    res = list(github_._make_github_repos_(*args))
  File "/tmp/dl-miniconda-z1552950/lib/python3.8/site-packages/datalad/support/github_.py", line 212, in _make_github_repos_
    res_ = _make_github_repo(
  File "/tmp/dl-miniconda-z1552950/lib/python3.8/site-packages/datalad/support/tests/test_github_.py", line 104, in _make_github_repo
    raise gh.BadCredentialsException("very bad status", "some data")
TypeError: __init__() missing 1 required positional argument: 'headers'
```

https://travis-ci.com/github/datalad/datalad/jobs/501116612#L2417

Comments:

Patch:
diff --git a/datalad/support/github_.py b/datalad/support/github_.py
index 6848a6785..10c3023d7 100644
--- a/datalad/support/github_.py
+++ b/datalad/support/github_.py
@@ -79,6 +79,17 @@ def _get_tokens_for_login(login, tokens):
     return selected_tokens
 
 
+def _gh_exception(exc_cls, status, data):
+    """Compatibility wrapper for instantiating a GithubException.
+    """
+    try:
+        exc = exc_cls(status, data, None)
+    except TypeError:
+        # Before PyGithub 1.5, GithubException had only two required arguments.
+        exc = exc_cls(status, data)
+    return exc
+
+
 def _gen_github_ses(github_login):
     """Generate viable Github sessions
 
@@ -96,7 +107,8 @@ def _gen_github_ses(github_login):
 
     """
     if github_login == 'disabledloginfortesting':
-        raise gh.BadCredentialsException(403, 'no login specified')
+        raise _gh_exception(gh.BadCredentialsException,
+                            403, 'no login specified')
 
     # see if we have tokens - might be many. Doesn't cost us much so get at once
     tokens = unique(


Test patch:
diff --git a/datalad/support/tests/test_github_.py b/datalad/support/tests/test_github_.py
index a8eaa212b..acbc22cda 100644
--- a/datalad/support/tests/test_github_.py
+++ b/datalad/support/tests/test_github_.py
@@ -33,6 +33,7 @@ from .. import github_
 from ..github_ import (
     _gen_github_entity,
     _get_github_cred,
+    _gh_exception,
     _token_str,
     get_repo_url,
 )
@@ -105,7 +106,8 @@ def test__make_github_repos():
 
     def _make_github_repo(github_login, entity, reponame, *args):
         if entity == 'entity1':
-            raise gh.BadCredentialsException("very bad status", "some data")
+            raise _gh_exception(gh.BadCredentialsException,
+                                "very bad status", "some data")
         return reponame
 
     with mock.patch.object(github_, '_gen_github_entity', _gen_github_entity), \
@@ -117,7 +119,8 @@ def test__make_github_repos():
 
     def _make_github_repo(github_login, entity, reponame, *args):
         # Always throw an exception
-        raise gh.BadCredentialsException("very bad status", "some data")
+        raise _gh_exception(gh.BadCredentialsException,
+                            "very bad status", "some data")
 
     with mock.patch.object(github_, '_gen_github_entity', _gen_github_entity), \
             mock.patch.object(github_, '_make_github_repo', _make_github_repo):