diff --git a/changelog.md b/changelog.md index d5518172..6efe0a02 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ > This version is not released yet and is under active development. - Fix conflicting detection heuristics for Linux distributions. Closes #72. +- Fix fetching of macOS version for releases without build number (like `15.0`). ## [1.3.0 (2024-09-11)](https://github.com/kdeldycke/extra-platforms/compare/v1.2.1...v1.3.0) diff --git a/extra_platforms/platforms.py b/extra_platforms/platforms.py index c383bf32..6c29ed87 100644 --- a/extra_platforms/platforms.py +++ b/extra_platforms/platforms.py @@ -184,28 +184,34 @@ def info(self) -> dict[str, str | bool | None | dict[str, str | None]]: # Add extra macOS infos. if self.id == "macos": release, _versioninfo, _machine = platform.mac_ver() - major, minor, build_number = release.split(".", 2) + parts = dict( + zip(("major", "minor", "build_number"), release.split(".", 2)) + ) mac_info = { "version": release, "version_parts": { - "major": major, - "minor": minor, - "build_number": build_number, + "major": parts.get("major"), + "minor": parts.get("minor"), + "build_number": parts.get("build_number"), }, - "codename": _get_macos_codename(major, minor), + "codename": _get_macos_codename( + parts.get("major"), parts.get("minor") + ), } info = _recursive_update(info, mac_info, strict=True) # Add extra Windows infos. elif self.id == "windows": release, version, _csd, _ptype = platform.win32_ver() - major, minor, build_number = version.split(".", 2) + parts = dict( + zip(("major", "minor", "build_number"), version.split(".", 2)) + ) win_info = { "version": release, "version_parts": { - "major": major, - "minor": minor, - "build_number": build_number, + "major": parts.get("major"), + "minor": parts.get("minor"), + "build_number": parts.get("build_number"), }, "codename": " ".join((release, platform.win32_edition())), }