Skip to content

Commit

Permalink
executors: use shutil.which instead of deprecated distutils
Browse files Browse the repository at this point in the history
See PEP 632, which suggests replacing distutils.spawn.find_executable with shutil.which.
  • Loading branch information
quantum5 committed Sep 22, 2021
1 parent 9704d41 commit 04bc78c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions dmoj/executors/base_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import sys
import tempfile
import traceback
from distutils.spawn import find_executable
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union

from dmoj.cptbox import IsolateTracer, TracedPopen, syscalls
Expand Down Expand Up @@ -413,7 +412,7 @@ def find_command_from_list(cls, files: List[str]) -> Optional[str]:
if os.path.exists(file):
return file
else:
path = find_executable(file)
path = shutil.which(file)
if path is not None:
return os.path.abspath(path)
return None
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/shell_executor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import shutil
import sys
from distutils.spawn import find_executable

from dmoj.executors.script_executor import ScriptExecutor

Expand All @@ -13,7 +13,7 @@ def get_shell_commands(self):
return self.shell_commands

def get_allowed_exec(self):
return list(map(find_executable, self.get_shell_commands()))
return list(map(shutil.which, self.get_shell_commands()))

def get_fs(self):
return super().get_fs() + self.get_allowed_exec()
Expand Down

0 comments on commit 04bc78c

Please sign in to comment.