From 60c605b7000b75fd145af8a8b4edb177f12c39dd Mon Sep 17 00:00:00 2001 From: Alex Thiel Date: Thu, 1 Jul 2021 10:13:52 -0700 Subject: [PATCH] Disallow minor version mismatching until vcap's major version is >= 1 (#36) --- vcap/vcap/loading/capsule_loading.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vcap/vcap/loading/capsule_loading.py b/vcap/vcap/loading/capsule_loading.py index d21e64e..f98a4d1 100644 --- a/vcap/vcap/loading/capsule_loading.py +++ b/vcap/vcap/loading/capsule_loading.py @@ -91,6 +91,17 @@ def load_capsule_from_bytes(data: bytes, f"capsule's OpenVisionCapsules required major version is " f"{major} but this software uses OpenVisionCapsules " f"{MAJOR_COMPATIBLE_VERSION}.{MINOR_COMPATIBLE_VERSION}.") + elif (MAJOR_COMPATIBLE_VERSION == 0 + and minor != MINOR_COMPATIBLE_VERSION): + # Because vcap has not yet reached a 1.0 API, while the major + # version is 0 then minor version will be required to match. + raise IncompatibleCapsuleError( + "The capsule is not compatible with this software. The " + "capsule's OpenVisionCapsules required version is " + f"{major}.{minor}, but this software uses OpenVisionCapsules " + f"{MAJOR_COMPATIBLE_VERSION.MINOR_COMPATIBLE_VERSION}" + ) + if minor > MINOR_COMPATIBLE_VERSION: raise IncompatibleCapsuleError( f"The capsule requires a version of OpenVisionCapsules "