happyleavesaoc / aoc-mgz

Age of Empires II recorded game parsing and summarization in Python 3.
MIT License
197 stars 41 forks source link

Parsing incorrect bytes when using summary snippet in README file #80

Closed NathanFlegg closed 2 years ago

NathanFlegg commented 2 years ago

The full error I'm getting is:

/<my_absolute_path>/bin/python3 /<my_absolute_path>/test.py
could not fast parse; falling back
Traceback (most recent call last):
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 2784, in _parse
    return self.subcon._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 1936, in _parse
    raise ConstError("expected %r but parsed %r" % (self.value, obj))
construct.core.ConstError: expected b'`\n' but parsed b'\x00\x00'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/<my_absolute_path>/lib/python3.9/site-packages/mgz/summary/full.py", line 73, in __init__
    self._header = mgz.header.parse_stream(self._handle)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 295, in _parse
    return self.subcon._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 295, in _parse
    return self.subcon._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/mgz/util.py", line 58, in _parse
    return self.subcon._parse(new_stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 357, in _parse
    return self.subcon.parse(data, context)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 158, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 2784, in _parse
    return self.subcon._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 1594, in _parse
    obj = self.cases.get(key, self.default)._parse(stream, context, path)
  File "/<my_absolute_path>/lib/python3.9/site-packages/construct/core.py", line 2788, in _parse
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.ConstError: expected b'`\n' but parsed b'\x00\x00'
    (parsing) -> de -> de

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/<my_absolute_path>/test.py", line 4, in <module>
    s = Summary(data)
  File "/<my_absolute_path>/lib/python3.9/site-packages/mgz/summary/__init__.py", line 22, in __call__
    return FullSummary(data, playback)
  File "/<my_absolute_path>/lib/python3.9/site-packages/mgz/summary/full.py", line 85, in __init__
    raise RuntimeError("invalid mgz file: {}".format(e))
RuntimeError: invalid mgz file: expected b'`\n' but parsed b'\x00\x00'
    (parsing) -> de -> de

I've removed my actual path to make it a bit more readable.

I don't know what could be causing this, I made a fresh venv for this on Python 3.9.7. I'm using Ubuntu 20.04, in case that might be making a difference. My pip list is pretty bare because this is a new venv but here it is anyway, in case it helps:

Package            Version
------------------ -----------
aiohttp            3.8.1
aiosignal          1.2.0
aocref             2.0.4
async-timeout      4.0.2
attrs              21.4.0
certifi            2022.5.18.1
charset-normalizer 2.0.12
construct          2.8.16
flatbuffers        2.0
frozenlist         1.3.0
idna               3.3
mgz                1.7.3
multidict          6.0.2
pip                21.2.3
pycountry          22.3.5
requests           2.27.1
ruamel.yaml        0.17.21
ruamel.yaml.clib   0.2.6
setuptools         57.4.0
tabulate           0.8.9
tqdm               4.64.0
urllib3            1.26.9
yarl               1.7.2

Do you know what might be causing this strange byte parsing error? I would really appreciate the help!

happyleavesaoc commented 2 years ago

Hi, please provide the recorded game file

NathanFlegg commented 2 years ago

rec.zip

happyleavesaoc commented 2 years ago

Is P2 an AI? If so, AI is not supported.

NathanFlegg commented 2 years ago

Ah sorry, thank you. I'll close this one.