Menu

#27 metaclass conflict on Python 3.3

v1.0 (example)
closed-fixed
nobody
None
5
2014-08-29
2013-08-10
No

I've installed comtypes 0.6.2 on Python 3.3.2 on Windows, but on importing comtypes, I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python\lib\site-packages\comtypes-0.6.2-py3.3-win-amd64.egg\comtypes\__init__.py", line 1049, in <module>
    class IUnknown(object, metaclass=_cominterface_meta):
  File "c:\python\lib\site-packages\comtypes-0.6.2-py3.3-win-amd64.egg\comtypes\__init__.py", line 281, in __new__
    class _(partial.partial, POINTER(p)):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Discussion

  • Arun

    Arun - 2013-08-12

    Here's a temporary patch: https://gist.github.com/codito/6207739. I have tried with comtypes svn snapshot (from trunk, after a 2to3.py conversion).

     
  • Jason R. Coombs

    Jason R. Coombs - 2014-01-20

    @Arun: Do you have a copy of the temporary patch? The referenced gist is no longer available.

    This issue is blocking the 'jaraco.video' project (https://bitbucket.org/jaraco/jaraco.video).

     
  • Jason R. Coombs

    Jason R. Coombs - 2014-01-20

    Thanks Arun. Silly that I missed the extraneous period in the link.

    Based on that patch, I've applied this patch to the source:

    https://bitbucket.org/jaraco/comtypes/commits/b85ebb181c17cc110bf486100c038434ff68ee8c

    That commit should work under Python 2 and converts to Python 3 to accomplish the aforementioned patch (with a couple of other locations where the metaclass had to be constructed.

    I think the proper fix for this is simply to not use metaclasses for the 'partial' and instead just monkey-patch the classes in place. In any case, the jaraco.video project is no longer blocked based on this workaround.

     
  • Jason R. Coombs

    Jason R. Coombs - 2014-02-02

    Fixed and released in 1.0.0.

     
  • Jason R. Coombs

    Jason R. Coombs - 2014-02-02
    • status: open --> closed-fixed
     

Log in to post a comment.