I'm trying to convert one of my Python module using Cython. Cython successfully generates a .pyd file, but when I try to import it, it fails:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
>>> import example
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "example.py", line 6, in init example
@abstractmethod
File "C:\Program Files\Python3\lib\abc.py", line 23, in abstractmethod
funcobj.__isabstractmethod__ = True
AttributeError: attribute '__isabstractmethod__' of 'staticmethod' objects is not writable
My module contains a method which is both abstract and static:
from abc import abstractmethod
class c:
@abstractmethod
@staticmethod
def foo():
raise NotImplementedError
According to https://docs.python.org/3/library/abc.html#abc.abstractmethod this should be possible. If I remove the @abstractmethod annotation, I can cythonize and import the module. It also works if i use @abstractstaticmethod, but that decorator is deprecated in abc.
Is this a Cython bug, or am I doing something wrong? I'm using Cython version 0.28.5 with Build Tools für Visual Studio 2017 on Windows 7.