[Tracker-discuss] [issue426] ctypeslib codegenerator chokes on CvQualifiedType

Loic Jaquemet metatracker at psf.upfronthosting.co.za
Sat Nov 19 06:58:46 CET 2011


New submission from Loic Jaquemet <loic.jaquemet+python at gmail.com>:

When using xml2py from the ctypeslib codegenerator 
http://svn.python.org/projects/ctypes/trunk/ctypeslib/ctypeslib/codegen/codegenerator.py

Attribute CVQualifiedType are not correctly parsed.
There are no size and align attributes.
We should use the super-type size and align attribute.
patch attached

Traceback (most recent call last):
  File "/usr/bin/xml2py", line 6, in <module>
    sys.exit(main())
  File "/usr/lib/pymodules/python2.7/ctypeslib/xml2py.py", line 199, in main
    types=options.kind)
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 873, in generate_code
    loops = gen.generate_code(items)
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 784, in generate_code
    loops = self.generate_items(items)
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 773, in generate_items
    self.generate_all(sorted(items, self.cmpitems))
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 757, in generate_all
    self.generate(item)
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 753, in generate
    mth(item)
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 401, in Structure
    self.generate(struct.get_body())
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 753, in generate
    mth(item)
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 560, in StructureBody
    pack = calc_packing(body.struct, fields)
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 124, in calc_packing
    _calc_packing(struct, fields, pack, isStruct)
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 97, in _calc_packing
    s, a = storage(f.typ)
  File "/usr/lib/pymodules/python2.7/ctypeslib/codegen/codegenerator.py", line 75, in storage
    return int(t.size), int(t.align)
AttributeError: 'CvQualifiedType' object has no attribute 'size'

----------
files: codegenerator.py.diff
messages: 2306
nosy: trolldbois
priority: bug
status: unread
title: ctypeslib codegenerator chokes on CvQualifiedType

_______________________________________________________
PSF Meta Tracker <metatracker at psf.upfronthosting.co.za>
<http://psf.upfronthosting.co.za/roundup/meta/issue426>
_______________________________________________________
-------------- next part --------------
--- codegenerator.py.orig	2011-02-18 08:16:47.000000000 -0500
+++ codegenerator.py	2011-11-19 00:47:13.197943171 -0500
@@ -72,6 +72,8 @@
         if t.max.lower() == GCCXML_NOSIZE:
             return 0, a
         return s * (int(t.max) - int(t.min) + 1), a
+    elif isinstance(t, typedesc.CvQualifiedType):
+        return int(t.typ.size), int(t.typ.align)
     return int(t.size), int(t.align)
 
 class PackingError(Exception):


More information about the Tracker-discuss mailing list