Skip to content

Commit 5c61667

Browse files
committed
use try except
1 parent 589a3db commit 5c61667

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/pygambit/game.pxi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@ class GamePlayers:
307307
raise ValueError(f"Game has multiple players with label '{index}'")
308308
return matches[0]
309309
if isinstance(index, int):
310-
if index in range(self.game.deref().NumPlayers()):
310+
try:
311311
return Player.wrap(self.game.deref().GetPlayer(index + 1))
312-
else:
313-
raise IndexError("Index out of range")
312+
except IndexError:
313+
raise IndexError("Index out of range") from None
314314
raise TypeError(f"Player index must be int or str, not {index.__class__.__name__}")
315315

316316
@property

0 commit comments

Comments
 (0)