From 0752a202aa61b424c0c7a55eece75a40ae8267fe Mon Sep 17 00:00:00 2001 From: Newbyte Date: Fri, 22 Nov 2024 11:34:39 +0100 Subject: [PATCH] pmb.core.arch: Handle unsupported arches in from_machine_type() better (MR 2498) Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2501 --- pmb/core/arch.py | 2 ++ pmb/core/test_arch.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/pmb/core/arch.py b/pmb/core/arch.py index 237cdcce..409e8df8 100644 --- a/pmb/core/arch.py +++ b/pmb/core/arch.py @@ -61,6 +61,8 @@ class Arch(enum.Enum): return Arch.armhf case "armv7l" | "armv8l": return Arch.armv7 + case _: + raise ValueError(f"Unsupported machine type '{machine_type}'") @staticmethod def native() -> "Arch": diff --git a/pmb/core/test_arch.py b/pmb/core/test_arch.py index 7598eab5..a91a6130 100644 --- a/pmb/core/test_arch.py +++ b/pmb/core/test_arch.py @@ -77,3 +77,7 @@ def test_invalid_arches(): with pytest.raises(TypeError) as excinfo: "bap" / Arch.aarch64 assert "unsupported operand type(s) for /: 'str' and 'Arch'" in str(excinfo.value) + + with pytest.raises(ValueError) as excinfo: + Arch.from_machine_type("invalid") + assert "Unsupported machine type 'invalid'" in str(excinfo.value)