aoc-mgz icon indicating copy to clipboard operation
aoc-mgz copied to clipboard

Issue using parse_match() function in python 3.10

Open qjorge21 opened this issue 1 year ago • 4 comments

Hi there!

I have an issue when I try to test the "to JSON" example, that uses the function parse_match() from mgz.model. The error message is:

Traceback (most recent call last):
  File "C:\Users\George\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mgz\fast\header.py", line 515, in parse
    de = parse_de(header, version, save)
  File "C:\Users\George\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mgz\fast\header.py", line 341, in parse_de
    strings.append(de_string(data).decode('utf-8').split(':'))
  File "C:\Users\George\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mgz\fast\header.py", line 47, in de_string
    assert data.read(2) == b'\x60\x0a'
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\George\Desktop\Script python\prueba.py", line 5, in <module>
    match = parse_match(h)
  File "C:\Users\George\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mgz\model\__init__.py", line 103, in parse_match
    data = parse(handle)
  File "C:\Users\George\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\mgz\fast\header.py", line 523, in parse
    raise RuntimeError(f"could not parse: {e}")
RuntimeError: could not parse:

I'm using python 3.10 and one rec from the last version of DE. I don't know if this works with python 3.7 or above. I hope that u can help me with that. Thanks!

qjorge21 avatar Sep 04 '22 23:09 qjorge21

Test code:

import json
from mgz.model import parse_match, serialize

with open('./recs/custom.aoe2record', 'rb') as h:
    match = parse_match(h)

qjorge21 avatar Sep 04 '22 23:09 qjorge21

Please provide the rec

happyleavesaoc avatar Sep 04 '22 23:09 happyleavesaoc

custom.zip

qjorge21 avatar Sep 04 '22 23:09 qjorge21

Parsing bug confirmed on this particular rec. Other recs work ok?

happyleavesaoc avatar Sep 05 '22 15:09 happyleavesaoc

Fixed in 1.7.11.

happyleavesaoc avatar Oct 03 '22 11:10 happyleavesaoc