From 07a7b06dd8c6dc08c789505f263986e5f084f802 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 24 Dec 2016 14:21:02 -0500 Subject: Traverse the class hierarchy when searching for the unpatched class. Ref #889. --- setuptools/monkey.py | 13 +++++++++---- 1 file 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(): -- cgit v1.2.3