changeset: 97443:73984e665bf5 branch: 3.5 parent: 97441:01d91caa58b6 user: Yury Selivanov date: Tue Aug 18 14:20:00 2015 -0400 files: Lib/functools.py Lib/test/test_functools.py Misc/NEWS description: Issue #23572: Fixed functools.singledispatch on classes with falsy metaclasses. Patch by Ethan Furman. diff -r 01d91caa58b6 -r 73984e665bf5 Lib/functools.py --- a/Lib/functools.py Tue Aug 18 13:27:18 2015 -0400 +++ b/Lib/functools.py Tue Aug 18 14:20:00 2015 -0400 @@ -567,7 +567,7 @@ break # reject the current head, it appears later else: break - if not candidate: + if candidate is None: raise RuntimeError("Inconsistent hierarchy") result.append(candidate) # remove the chosen candidate diff -r 01d91caa58b6 -r 73984e665bf5 Lib/test/test_functools.py --- a/Lib/test/test_functools.py Tue Aug 18 13:27:18 2015 -0400 +++ b/Lib/test/test_functools.py Tue Aug 18 14:20:00 2015 -0400 @@ -1491,6 +1491,24 @@ many_abcs = [c.Mapping, c.Sized, c.Callable, c.Container, c.Iterable] self.assertEqual(mro(X, abcs=many_abcs), expected) + def test_false_meta(self): + # see issue23572 + class MetaA(type): + def __len__(self): + return 0 + class A(metaclass=MetaA): + pass + class AA(A): + pass + @functools.singledispatch + def fun(a): + return 'base A' + @fun.register(A) + def _(a): + return 'fun A' + aa = AA() + self.assertEqual(fun(aa), 'fun A') + def test_mro_conflicts(self): c = collections @functools.singledispatch diff -r 01d91caa58b6 -r 73984e665bf5 Misc/NEWS --- a/Misc/NEWS Tue Aug 18 13:27:18 2015 -0400 +++ b/Misc/NEWS Tue Aug 18 14:20:00 2015 -0400 @@ -2,6 +2,29 @@ Python News +++++++++++ + +What's New in Python 3.5.1 +========================== + + +Release date: TBA + + +Core and Builtins +----------------- + + +Library +------- + +- Issue #23572: Fixed functools.singledispatch on classes with falsy + metaclasses. Patch by Ethan Furman. + + +Documentation +------------- + + What's New in Python 3.5.0 release candidate 2? ===============================================