From 97573e156e5c42ebdc4fb5b4503a27c1ed5f02dd Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Fri, 8 May 2026 17:48:39 +0300 Subject: [PATCH] CI: add_version: correctly handle exceptions exit code 1 is used as a signal that no new version is found -- so have to use a different exit code for unhandled exceptions --- .github/workflows/add_version.yml | 2 ++ plugins/python-build/scripts/add_cpython.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/add_version.yml b/.github/workflows/add_version.yml index 74575c0e..23c2b6fd 100644 --- a/.github/workflows/add_version.yml +++ b/.github/workflows/add_version.yml @@ -25,6 +25,8 @@ jobs: - name: check for a release run: | python plugins/python-build/scripts/add_cpython.py --verbose >added_versions.lst && rc=$? || rc=$? + #0 means new version found, 1 not found, 2 another error + [[ $rc -gt 1 ]] && false echo "rc=$rc" >> $GITHUB_ENV - name: set PR properties if: env.rc == 0 diff --git a/plugins/python-build/scripts/add_cpython.py b/plugins/python-build/scripts/add_cpython.py index 8c05a066..fc4edb71 100755 --- a/plugins/python-build/scripts/add_cpython.py +++ b/plugins/python-build/scripts/add_cpython.py @@ -30,6 +30,13 @@ import requests_html import sortedcontainers import tqdm +#CI uses exit code 1 as a signal that no new version is found +#so have to produce a different exit code on an exception +def _excepthook(type,value,traceback): + logging.error("Unhandled exception occured",exc_info=(type,value,traceback)) + sys.exit(2) +sys.excepthook = _excepthook + logger = logging.getLogger(__name__) CUTOFF_VERSION=packaging.version.Version('3.10')