Any comment on using ctypesgen package?

jfong at ms4.hinet.net jfong at ms4.hinet.net
Sat Mar 5 03:14:28 EST 2016


Chris Angelico at 2016/3/5  UTC+8 1:50:05PM wrote:
> Your conclusion may well be correct. However, the exact issue you're
> looking at here might be easily enough fixed; it looks like it's
> trying to sort things by length, so you can simply use "key=len" (and
> maybe "reverse=True").

After Chris gave this suggestion, I can't withstand the temptation of running the setup again. This time, strangely, it reports error on import. Won't the import statement easy enough to be handled by 2To3? Here is the result (where the whole "ctypesgencore" directory had been processed by 2To3 and the "parser" is a sub-directory under it):

----------
D:\Patch\ctypesgen-master>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 13, in <module>
    import ctypesgencore
  File "D:\Patch\ctypesgen-master\ctypesgencore\__init__.py", line 55, in <modul
e>
    from . import parser
  File "D:\Patch\ctypesgen-master\ctypesgencore\parser\__init__.py", line 17, in
 <module>
    from .datacollectingparser import DataCollectingParser
  File "D:\Patch\ctypesgen-master\ctypesgencore\parser\datacollectingparser.py",
 line 10, in <module>
    from . import ctypesparser
  File "D:\Patch\ctypesgen-master\ctypesgencore\parser\ctypesparser.py", line 15
, in <module>
    from .cparser import *
  File "D:\Patch\ctypesgen-master\ctypesgencore\parser\cparser.py", line 21, in
<module>
    from . import cgrammar
  File "D:\Patch\ctypesgen-master\ctypesgencore\parser\cgrammar.py", line 25, in
 <module>
    from . import ctypesparser
ImportError: cannot import name 'ctypesparser'
------------

Just curious, is there a recursive-import happen on handling the "parser" directory?

After checking the files, I had noticed that all the import statements had been changed by 2To3. Mostly the changes are, such as, from "import cgrammar" to "from . import cgrammar", or "from cparser import *" to "from .cparset import *". I can understand the former, but can't figure out the latter:-(

--Jach



More information about the Python-list mailing list