Skip to content

Codefix: Index equal to the list length is also invalid#434

Open
Rito13 wants to merge 1 commit into
OpenTTD:masterfrom
Rito13:fix_index_out_of_range
Open

Codefix: Index equal to the list length is also invalid#434
Rito13 wants to merge 1 commit into
OpenTTD:masterfrom
Rito13:fix_index_out_of_range

Conversation

@Rito13

@Rito13 Rito13 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

In python list indexes are in range 0..(len(list) - 1).
Therefore custom_spritesets[len(custom_spritesets)] will fail.

Replace the invalid > with >=.

@LordAro

LordAro commented Jun 22, 2026

Copy link
Copy Markdown
Member

The "pythonic" way would be a try/except IndexError

@Rito13 Rito13 force-pushed the fix_index_out_of_range branch from f73b844 to 1963d94 Compare June 22, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants