Skip to content

Error getting race letter for race-less player #232

Description

@Alzarath

I got a report from a player about my map's replays breaking their script. When I tested it with a replay of my own, I got the following error:

--------------------------------------
/home/alzarath/Documents/StarCraft II/Accounts/#######/#-S#-#-######/Replays/Multiplayer/Impossible Cyrus (87).SC2Replay

   Map:      Impossible Cyrus
   Date:     2025-11-22 18:28:13+00:00
Error with '/home/alzarath/Documents/StarCraft II/Accounts/#######/#-S#-#-######/Replays/Multiplayer/Impossible Cyrus (87).SC2Replay': 
string index out of range
Traceback (most recent call last):
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/scripts/sc2printer.py", line 175, in <module>
    main()
    ~~~~^^
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/scripts/sc2printer.py", line 168, in main
    printReplay(filepath, arguments)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/scripts/sc2printer.py", line 23, in printReplay
    lineups = [team.lineup for team in replay.teams]
               ^^^^^^^^^^^
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/objects.py", line 48, in lineup
    return "".join(sorted(p.play_race[0].upper() for p in self.players))
                   ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/objects.py", line 48, in <genexpr>
    return "".join(sorted(p.play_race[0].upper() for p in self.players))
                          ~~~~~~~~~~~^^^
IndexError: string index out of range

My CPU player, the seventh player, Player 14, is considered "Neutral" for its race (set in the Player Properties). The script appears to read this as an empty string, so there's no first letter to return.

Here's the replay in question. Impossible Cyrus (87).SC2Replay.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions