diff options
Diffstat (limited to 'setuptools/monkey.py')
-rw-r--r-- | setuptools/monkey.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/setuptools/monkey.py b/setuptools/monkey.py index 94f22a56..6d3711ec 100644 --- a/setuptools/monkey.py +++ b/setuptools/monkey.py @@ -21,6 +21,20 @@ if you think you need this functionality. """ +def _get_mro(cls): + """ + Returns the bases classes for cls sorted by the MRO. + + Works around an issue on Jython where inspect.getmro will not return all + base classes if multiple classes share the same name. Instead, this + function will return a tuple containing the class itself, and the contents + of cls.__bases__. See https://github.com/pypa/setuptools/issues/1024. + """ + if platform.python_implementation() == "Jython": + return (cls,) + cls.__bases__ + return inspect.getmro(cls) + + def get_unpatched(item): lookup = ( get_unpatched_class if isinstance(item, six.class_types) else @@ -38,7 +52,7 @@ def get_unpatched_class(cls): """ external_bases = ( cls - for cls in inspect.getmro(cls) + for cls in _get_mro(cls) if not cls.__module__.startswith('setuptools') ) base = next(external_bases) |