From 3d577aa3f52e16b1f8a8d1ede75c8d1379369bd2 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Fri, 7 Oct 2022 20:13:24 +0100 Subject: [PATCH] hg-92886: [clinic.py] raise exception on invalid input instead of assertion --- Lib/test/test_clinic.py | 2 +- Tools/clinic/clinic.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py index 4aa9691a4829d1..8ab40c694f711d 100644 --- a/Lib/test/test_clinic.py +++ b/Lib/test/test_clinic.py @@ -153,7 +153,7 @@ def test_right_only(self): def test_have_left_options_but_required_is_empty(self): def fn(): clinic.permute_optional_groups(['a'], [], []) - self.assertRaises(AssertionError, fn) + self.assertRaises(ValueError, fn) class ClinicLinearFormatTest(TestCase): diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 30a676328706f6..a8687e3470a185 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -495,7 +495,8 @@ def permute_optional_groups(left, required, right): result = [] if not required: - assert not left + if left: + raise ValueError("required is empty but left is not") accumulator = [] counts = set()