Elide traceback when python -m uv in interrupted with Ctrl-C on Windows (#14715)

Closes https://github.com/astral-sh/uv/issues/14704
This commit is contained in:
Zanie Blue 2025-07-18 08:07:36 -05:00 committed by GitHub
parent 70875128be
commit a186fda2d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,7 +37,12 @@ def _run() -> None:
if sys.platform == "win32":
import subprocess
completed_process = subprocess.run([uv, *sys.argv[1:]], env=env)
# Avoid emitting a traceback on interrupt
try:
completed_process = subprocess.run([uv, *sys.argv[1:]], env=env)
except KeyboardInterrupt:
sys.exit(2)
sys.exit(completed_process.returncode)
else:
os.execvpe(uv, [uv, *sys.argv[1:]], env=env)