Any comment on using ctypesgen package?

Peter Otten __peter__ at web.de
Fri Mar 4 07:35:24 EST 2016


jfong at ms4.hinet.net wrote:

> I try to test this package but with no luck. This module was written for
> Python 2.x but mine is 3.4 so I use the 2To3 to "upgrade" it first (it
> seems OK). Then I run "python setup.py install" and get the following
> error:
>    ...
>    ...
>    File "D:\Patch\ctypesgen-master\ctypesgencore\parser\lex.py", line 41,
>    in <module>
>     _INSTANCETYPE = types.InstanceType
>    AttributeError: 'module' object has no attribute 'InstanceType'
> 
> Below is the troubled codes in file lex.py:
> Note: In original codes (before 2To3 modify), there is "types.ObjectType"
> instead of "object". ---------
> # Available instance types.  This is used when lexers are defined by a
> # class. It's a little funky because I want to preserve backwards
> # compatibility with Python 2.0 where types.ObjectType is undefined.
> try:
>     _INSTANCETYPE = (types.InstanceType, object)
> except AttributeError:
>     _INSTANCETYPE = types.InstanceType
>     class object: pass   # Note: needed if no new-style classes present
> -----------
> The author had put some comments above these codes but I have no idea what
> he is talking about.
> 
> There is someone who had encountered the same problem last year and raise
> a question at its home page, but the author seems has no interest on doing
> anything on it anymore.
> https://github.com/davidjamesca/ctypesgen/issues/53
> 
> Does anyone know how to fix it? or the whole job will be a mission
> impossible if no help from its author?

Nothing is impossible with open source ;)

What's possible for you depends on your knowledge and the amount of effort 
you are willing to spend. The page you link to has the comment

"""
The 2to3 route is not likely to apply since ctypesgen actually writes Python 
code and the 2to3 utility will probably miss a good portion of that logic.
"""

But as someone else seems to have done the work already

https://github.com/davidjamesca/ctypesgen/issues/51

I'd try his version first.





More information about the Python-list mailing list