zope.interface icon indicating copy to clipboard operation
zope.interface copied to clipboard

Issue with cythonized interfaces

Open hoefling opened this issue 7 years ago • 1 comments

When compiling interfaces into shared objects, zope cannot resolve them correctly. For an SSCCE, the compiled example interface from https://docs.zope.org/zope.interface/README.html raises

zope.interface.exceptions.InvalidInterface: Concrete attribute, name

I collected the procedure in a bash script (https://gist.github.com/hoefling/c113a46f1690118ef4bde3114b2960c7). It generates a python module containing the interface and a test script that tries to import that interface:

Without cythonizing:

$ source zopetest-generator 
$ python /tmp/tester.py 
import succeeded

With cythonizing:

$ source zopetest-generator --cythonize
$ python /tmp/tester.py 
Traceback (most recent call last):
  File "/tmp/tester.py", line 2, in <module>
    from zopetest.interface import IFoo
  File "zopetest/interface.py", line 2, in init zopetest.interface (/tmp/zopetest/interface.c:984)
  File "/usr/lib64/python3.5/site-packages/zope/interface/interface.py", line 369, in __init__
    raise InvalidInterface("Concrete attribute, " + name)
zope.interface.exceptions.InvalidInterface: Concrete attribute, bar

hoefling avatar Aug 12 '16 13:08 hoefling

@hoefling Thanks for the report! I'm not set up to make the --cythonize version run easily. Can you add some debugging to zope.interface.interface.InterfaceClass.__init__ to determine the name(s) / type(s) of the attributes which trigger the exception?

tseaver avatar Dec 06 '16 12:12 tseaver