Issue36881
Created on 2019-05-11 02:29 by emanspeaks, last changed 2022-04-11 14:59 by admin.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 27648 | closed | iritkatriel, 2021-08-07 00:47 | |
| Messages (3) | |||
|---|---|---|---|
| msg342152 - (view) | Author: Randy Eckman (emanspeaks) | Date: 2019-05-11 02:29 | |
>>> from abc import ABCMeta >>> class AbstractMeta(type, metaclass=ABCMeta): pass ... >>> class Meta1(AbstractMeta): pass ... >>> class Meta2(AbstractMeta): pass ... >>> class ClassA(metaclass=Meta1): pass ... >>> isinstance(ClassA, Meta2) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\miniconda\miniconda3\lib\abc.py", line 139, in __instancecheck__ return _abc_instancecheck(cls, instance) TypeError: __subclasscheck__() takes exactly one argument (0 given) This is driven by the fact that the metaclass of AbstractMeta is ABCMeta; if I change its metaclass to something else that does not contain ABCMeta in the inheritance chain, isinstance returns False as expected. Possibly related to Issue 2325? |
|||
| msg342870 - (view) | Author: Ivan Levkivskyi (levkivskyi) * ![]() |
Date: 2019-05-19 21:08 | |
I think this is related to how `__subclasscheck__` is implemented in `ABCMeta`. I just checked this also happens in Python 3.6 (i.e. it is not something specific to the C version introduced in Python 3.7). |
|||
| msg399162 - (view) | Author: Irit Katriel (iritkatriel) * ![]() |
Date: 2021-08-07 00:53 | |
PR27648 fixes this, but it also breaks test_abc.test_issubclass_bad_arguments so it's not quite right. I don't know this area, but I think the problem is in the place the PR changes, and that the issue is due to this difference in the type of __subclasses__ between C and Meta2: >>> class C: pass ... >>> from abc import ABCMeta >>> class AbstractMeta(type, metaclass=ABCMeta): pass ... >>> class Meta2(AbstractMeta): pass ... >>> C.__subclasses__ <built-in method __subclasses__ of type object at 0x7f96bf5040b0> >>> Meta2.__subclasses__ <method '__subclasses__' of 'type' objects> |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:15 | admin | set | github: 81062 |
| 2021-08-07 00:53:04 | iritkatriel | set | messages:
+ msg399162 versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.7 |
| 2021-08-07 00:47:26 | iritkatriel | set | keywords:
+ patch nosy: + iritkatriel pull_requests:
+ pull_request26142 |
| 2019-07-03 09:37:46 | myungsekyo | set | nosy:
+ myungsekyo |
| 2019-07-01 19:46:22 | donovick | set | nosy:
+ donovick |
| 2019-05-28 08:37:36 | Jeffrey.Kintscher | set | nosy:
+ Jeffrey.Kintscher |
| 2019-05-19 21:08:36 | levkivskyi | set | messages: + msg342870 |
| 2019-05-19 09:20:12 | levkivskyi | set | nosy:
+ levkivskyi |
| 2019-05-11 06:05:17 | SilentGhost | set | nosy:
+ rhettinger, stutzbach type: behavior |
| 2019-05-11 02:29:04 | emanspeaks | create | |
