我希望.tab
能够处理以下类:
abc.abstractmethod
但是这个小例子给了我
from abc import ABC
from my_cpp_module import my_class
class A(my_class, ABC):
@abstractmethod
def implement_me(self, arg):
'''not implemented'''
class B(A):
pass
b = B() <--- should throw
b.implement_me('hallo')
摆弄Traceback (most recent call last):
File "./abc-test.py", line 4, in <module>
class A(my_class, ABC):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
,类等等,我得到的运行没有错误:
type
..但在这种情况下class MyABC(type(my_class), ABCMeta):
pass # type(my_class) == <class 'Boost.Python.class'>
class A(my_class, metaclass=MyABC):
@abstractmethod
def implement_me(self, arg):
'''not implemented'''
也可以正常工作,但(当然)我希望它产生以下错误:
b = B()
有没有办法让File "./abc-test.py", line 22, in <module>
b = B()
TypeError: Can't instantiate abstract class B with abstract methods implement_me
与预期的Boost.Python类一起工作?