From 97573e156e5c42ebdc4fb5b4503a27c1ed5f02dd Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Fri, 8 May 2026 17:48:39 +0300 Subject: [PATCH 1/3] 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') From 5bb6b27d61fc579938c877004a9ab6d1537c0805 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Fri, 8 May 2026 18:18:59 +0300 Subject: [PATCH 2/3] CI: add_version: support prereleases for non-initial releases They unexpectedly made a prerelease 3.14.5rc1 --- plugins/python-build/scripts/add_cpython.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/python-build/scripts/add_cpython.py b/plugins/python-build/scripts/add_cpython.py index fc4edb71..c66ad822 100755 --- a/plugins/python-build/scripts/add_cpython.py +++ b/plugins/python-build/scripts/add_cpython.py @@ -199,11 +199,17 @@ def main(): VersionDirectory.existing.populate() VersionDirectory.available.populate() - for initial_release in (v for v in frozenset(VersionDirectory.available.keys()) - if v.micro == 0 and v not in VersionDirectory.existing): - # may actually be a prerelease - VersionDirectory.available.get_store_available_source_downloads(initial_release, True) - del initial_release + # Prereleases are placed under the same directory as the corresponding release. + # So until we know the release is out, its directory is a potential prerelease directory. + # Normally, prereleases are only made for initial releases (x.y.0) -- + # but rarely, they may make them for other releases (e.g. 3.14.5). + for release in (v for v in frozenset(VersionDirectory.available.keys()) #refining changes the + #corresponding directory key + #which breaks iteration + #so have to iterate over a copy + if v not in VersionDirectory.existing): + VersionDirectory.available.get_store_available_source_downloads(release, True) + del release versions_to_add = sorted(VersionDirectory.available.keys() - VersionDirectory.existing.keys()) From 3399b2e2e5eae25f6ddc3960b61d561e7d6ea7c0 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Fri, 8 May 2026 18:35:19 +0300 Subject: [PATCH 3/3] clarify confusing error message --- plugins/python-build/scripts/add_cpython.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/python-build/scripts/add_cpython.py b/plugins/python-build/scripts/add_cpython.py index c66ad822..0742dd7a 100755 --- a/plugins/python-build/scripts/add_cpython.py +++ b/plugins/python-build/scripts/add_cpython.py @@ -369,8 +369,8 @@ class CPythonAvailableVersionsDirectory(KeyedList[_CPythonAvailableVersionInfo, download_version = packaging.version.Version(m.group("version")) if download_version != version: if not refine_mode: - raise ValueError(f"Unexpectedly found a download {name} for {download_version} " - f"at page {entry.download_page_url} for {version}") + raise ValueError(f"Unexpectedly found a download {name} ({download_version}) " + f"for {version} at page {entry.download_page_url}") entry_to_fill = additional_versions_found.get_or_create( download_version, download_page_url=entry.download_page_url