Skip to content

better error handling in GamePlayers.__getitem__#702

Merged
tturocy merged 2 commits intomasterfrom
issue_697
Dec 15, 2025
Merged

better error handling in GamePlayers.__getitem__#702
tturocy merged 2 commits intomasterfrom
issue_697

Conversation

@rahulsavani
Copy link
Copy Markdown
Member

closes #697

return matches[0]
if isinstance(index, int):
return Player.wrap(self.game.deref().GetPlayer(index + 1))
if index in range(self.game.deref().NumPlayers()):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more Pythonic to do try-except here, being sure to raise the exception from None (so the stack trace starts here).

@rahulsavani rahulsavani requested a review from tturocy December 15, 2025 15:01
@tturocy tturocy merged commit 78ca12f into master Dec 15, 2025
28 checks passed
@tturocy tturocy deleted the issue_697 branch December 15, 2025 15:22
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.

[Enh]: Better error handling when trying to access a non-existent player via integer index

2 participants