midstar / pycstruct

A python library for reading and writing binary data similar to what is done in C language structs
MIT License
24 stars 4 forks source link

Bug when run on Python 3.8 #15

Closed hecko closed 7 months ago

hecko commented 3 years ago

This does not present itself when run on Python 3.9 on Mac, but does when the same script runs on Ubuntu Focals Python 3.8.5

Its probably related to #13 (the same header file)

pycstruct 0.6

definitions = pycstruct.parse_file('packet_structs.h')
Traceback (most recent call last):
  File "./reaper.py", line 9, in <module>
    definitions = pycstruct.parse_file('packet_structs.h')
  File "/usr/local/lib/python3.8/dist-packages/pycstruct/cparser.py", line 531, in parse_file
    type_meta = castxml_parser.parse()
  File "/usr/local/lib/python3.8/dist-packages/pycstruct/cparser.py", line 91, in parse
    supported_types[id] = self._parse_union(xml_union)
  File "/usr/local/lib/python3.8/dist-packages/pycstruct/cparser.py", line 170, in _parse_union
    self._set_common_meta(xml_union, union)
  File "/usr/local/lib/python3.8/dist-packages/pycstruct/cparser.py", line 213, in _set_common_meta
    name = xml_input.attrib['name']
KeyError: 'name'
midstar commented 3 years ago

This seems to be a difference in castxml version rather than python version. The name attribute is misding in the castxml output. I made a workaround that might work. Try pycstruct version 0.6.1.

Which versions of castxml are you using?

midstar commented 3 years ago

Please try this again using pycstruct version 0.7.0. I have changed some arguments used for generating xml from castxml. This might fix the issue.