[Python-checkins] cpython (merge 3.5 -> default): Merge 3.5 (issue #23572)
yury.selivanov
python-checkins at python.org
Tue Aug 18 20:26:09 CEST 2015
https://hg.python.org/cpython/rev/94d0c219d46f
changeset: 97444:94d0c219d46f
parent: 97442:80b3930b86ef
parent: 97443:73984e665bf5
user: Yury Selivanov <yselivanov at sprymix.com>
date: Tue Aug 18 14:23:02 2015 -0400
summary:
Merge 3.5 (issue #23572)
files:
Lib/functools.py | 2 +-
Lib/test/test_functools.py | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/Lib/functools.py b/Lib/functools.py
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -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 --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -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
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list