mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
Issue #23572: Fixed functools.singledispatch on classes with falsy metaclasses.
Patch by Ethan Furman.
This commit is contained in:
parent
f5e0c41d6d
commit
77a8cd65be
3 changed files with 42 additions and 1 deletions
|
@ -1491,6 +1491,24 @@ class TestSingleDispatch(unittest.TestCase):
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue