Debian Codegraph @

third_party/python/pip_tools/piptools/subprocess_utils.py

raw
1 # WARNING! BE CAREFUL UPDATING THIS FILE
2 # Consider possible security implications associated with subprocess module.
3 from __future__ import annotations
4
5 import subprocess # nosec
6
7
8 def run_python_snippet(python_executable: str, code_to_run: str) -> str:
9 """
10 Executes python code by calling python_executable with '-c' option.
11 """
12 py_exec_cmd = python_executable, "-c", code_to_run
13
14 # subprocess module should never be used with untrusted input
15 return subprocess.check_output( # nosec
16 py_exec_cmd,
17 shell=False,
18 text=True,
19 )