From ecf7b0d25dcfd916f53fd1aaa9402fbcd5f7e126 Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Tue, 18 Jul 2023 22:04:25 -0700 Subject: [PATCH] Python 3.11 compat fix random.sample() used to take arbitrary iterables, now it requires a sequence (i.e. something that can be indexed). --- src/debug/decorators.py | 2 +- src/pregame.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/debug/decorators.py b/src/debug/decorators.py index d40d7be6..e58ed7cd 100644 --- a/src/debug/decorators.py +++ b/src/debug/decorators.py @@ -135,7 +135,7 @@ def __exit__(self, exc_type: Optional[type], exc_value: Optional[BaseException], # sanitize paths in tb: convert backslash to forward slash and remove prefixes from src and library paths variables[1] = variables[1].replace("\\", "/") - variables[1] = re.sub(r'File "[^"]*/(src|gamemodes|oyoyo|roles|lib|wolfbot)', r'File "/\1', variables[1]) + variables[1] = re.sub(r'File "[^"]*/(src|gamemodes|oyoyo|roles|[Ll]ib|wolfbot)', r'File "/\1', variables[1]) # sanitize values within local frames if len(variables) > 3: diff --git a/src/pregame.py b/src/pregame.py index 6dbed6df..14190ee6 100644 --- a/src/pregame.py +++ b/src/pregame.py @@ -346,7 +346,7 @@ def _isvalid(mode, allow_vote_only): if count == 0 or role in ingame_state.current_mode.SECONDARY_ROLES: continue - selected = random.sample(vils, count) + selected = random.sample(list(vils), count) for x in selected: ingame_state.main_roles[x] = role vils.remove(x)