happyleavesaoc / aoc-mgz

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

SyntaxError: can't use starred expression here #48

Closed reactormonk closed 3 years ago

reactormonk commented 3 years ago

I've installed the library via pip install mgzdb and python 3.9, but I get

Traceback (most recent call last):
  File "/home/tass/.local/bin/mgzdb", line 5, in <module>
    from mgzdb.__main__ import setup
  File "~/.local/lib/python3.9/site-packages/mgzdb/__main__.py", line 8, in <module>
    from mgzdb.api import API
  File "~/.local/lib/python3.9/site-packages/mgzdb/api.py", line 12, in <module>
    from mgzdb.add import AddFile
  File "~/.local/lib/python3.9/site-packages/mgzdb/add.py", line 14, in <module>
    import mgz.summary
  File "~/.local/lib/python3.9/site-packages/mgz/summary/__init__.py", line 19, in <module>
    from mgz import fast
  File "~/.local/lib/python3.9/site-packages/mgz/fast.py", line 125
    player_id, formation_id, (*object_ids) = struct.unpack_from('<xhI' + str(data[0]) + 'I', data)
                              ^
SyntaxError: can't use starred expression here

Same with python 3.8.

sobeaa commented 3 years ago

Get running Python version from:

import sys

print(sys.version)

I'm unsure if a tuple with 2 or less objects from stuct.unpack_from would throw that error, seems more likely you're running the script on an older version of Python. Now, the parenthesis surrounding the starred expression might also be an issue, but I'm not an expert on interpreting that exact combination.

reactormonk commented 3 years ago
$ python --version
Python 3.9.2
J-Hinton commented 3 years ago

I also see the issue appearing in Python 3.9.2+. I've tested with 3.9.1 and below which works without any issues. There were a few changes in Python 3.9.2 which could have changed the behavior, but haven't had time to verify just yet.

J-Hinton commented 3 years ago

Python 3.9.2 RC1 implemented a bug fix (bpo-40631):

Python PR 24068 was merged in January to 3.9 branch.

I've seen @nymanjens is working on PR #50 to fix this issue.

reactormonk commented 3 years ago

Works on master, can confirm!