fix: replace assert with proper exception in python_build_standalone (#2859)

Assert statements are skipped under python -O, making them unsuitable
for runtime validation. Replace assert with an explicit check that
raises PythonBuildStandaloneError if the target directory already exists.

Assisted-by: OpenCode:glm-5
This commit is contained in:
Henry Schreiner
2026-05-17 11:26:29 -07:00
committed by GitHub
parent d08d9acda2
commit 51b25dc0aa
+3 -1
View File
@@ -175,7 +175,9 @@ def create_python_build_standalone_environment(
)
python_base_dir = temp_dir / "pbs"
assert not python_base_dir.exists()
if python_base_dir.exists():
msg = f"python-build-standalone directory already exists: {python_base_dir}"
raise PythonBuildStandaloneError(msg)
extract_tar(archive_path, python_base_dir)
return _find_python_executable(python_base_dir)