diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-12-24 14:21:02 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-12-24 14:21:02 -0500 |
commit | 07a7b06dd8c6dc08c789505f263986e5f084f802 (patch) | |
tree | d5e520a9885d7a173cbb0d1adfdaa9abea3ada01 /setuptools/monkey.py | |
parent | e2acd39745b32fb34ca4832377839448bcaa260b (diff) | |
download | external_python_setuptools-07a7b06dd8c6dc08c789505f263986e5f084f802.tar.gz external_python_setuptools-07a7b06dd8c6dc08c789505f263986e5f084f802.tar.bz2 external_python_setuptools-07a7b06dd8c6dc08c789505f263986e5f084f802.zip |
Traverse the class hierarchy when searching for the unpatched class. Ref #889.
Diffstat (limited to 'setuptools/monkey.py')
-rw-r--r-- | setuptools/monkey.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/setuptools/monkey.py b/setuptools/monkey.py index aabc280f..dbe9a617 100644 --- a/setuptools/monkey.py +++ b/setuptools/monkey.py @@ -7,6 +7,7 @@ import distutils.filelist import platform import types import functools +import inspect from .py26compat import import_module from setuptools.extern import six @@ -35,12 +36,16 @@ def get_unpatched_class(cls): Also ensures that no other distutils extension monkeypatched the distutils first. """ - while cls.__module__.startswith('setuptools'): - cls, = cls.__bases__ - if not cls.__module__.startswith('distutils'): + external_bases = ( + cls + for cls in inspect.getmro(cls) + if not cls.__module__.startswith('setuptools') + ) + base = next(external_bases) + if not base.__module__.startswith('distutils'): msg = "distutils has already been patched by %r" % cls raise AssertionError(msg) - return cls + return base def patch_all(): |