zopefoundation / zope.interface

Interfaces for Python
http://zopeinterface.readthedocs.io/
Other
317 stars 70 forks source link

Issue with cythonized interfaces #47

Open hoefling opened 8 years ago

hoefling commented 8 years ago

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
tseaver commented 7 years ago

@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?