Skip to content

Commit

Permalink
Traverse the class hierarchy when searching for the unpatched class. …
Browse files Browse the repository at this point in the history
…Ref #889.
  • Loading branch information
jaraco committed Dec 24, 2016
1 parent e2acd39 commit 07a7b06
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions setuptools/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import platform
import types
import functools
import inspect

from .py26compat import import_module
from setuptools.extern import six
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 07a7b06

Please sign in to comment.