diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2017-04-27 15:32:14 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-27 15:32:14 -0400 |
| commit | 498fec28f4c337346cbcca1bc57b8c509413633b (patch) | |
| tree | 873194b6d1876ef182f181a5aebc051c4731f13c | |
| parent | d8e1ed570126dfc99ed7f9126df3bfc890e7005d (diff) | |
| parent | 81c15b5010c3005ec8d77e89a3f974e54be8d10f (diff) | |
| download | external_python_setuptools-498fec28f4c337346cbcca1bc57b8c509413633b.tar.gz external_python_setuptools-498fec28f4c337346cbcca1bc57b8c509413633b.tar.bz2 external_python_setuptools-498fec28f4c337346cbcca1bc57b8c509413633b.zip | |
Merge pull request #1025 from LordGaav/fix-mro-on-jython. Fixes #1024.
Use a different method to lookup base classes on Jython
| -rw-r--r-- | CHANGES.rst | 5 | ||||
| -rw-r--r-- | setuptools/monkey.py | 16 |
2 files changed, 20 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index ebd18360..d83eb9d8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,8 @@ +v35.0.2 +------- + +* #1024: Add workaround for Jython #2581 in monkey module. + v35.0.1 ------- diff --git a/setuptools/monkey.py b/setuptools/monkey.py index 68fad9dd..acd0a4f4 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) |
