summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2022-10-07 21:41:35 (GMT)
committerGitHub <noreply@github.com>2022-10-07 21:41:35 (GMT)
commit34e6f3567e3519e0e8cdb7bbc4b68b9ab40493c8 (patch)
tree7c200854fd28185000051023611920c9405211b8
parent3de08ce8c15ab21a010d3bb0618ac42d15c8eff0 (diff)
downloadcpython-34e6f3567e3519e0e8cdb7bbc4b68b9ab40493c8.zip
cpython-34e6f3567e3519e0e8cdb7bbc4b68b9ab40493c8.tar.gz
cpython-34e6f3567e3519e0e8cdb7bbc4b68b9ab40493c8.tar.bz2
gh-92886: [clinic.py] raise exception on invalid input instead of assertion (GH-98051)
Tests should pass with -O (assertions off). Automerge-Triggered-By: GH:iritkatriel
-rw-r--r--Lib/test/test_clinic.py2
-rwxr-xr-xTools/clinic/clinic.py3
2 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index 4aa9691..8ab40c6 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -153,7 +153,7 @@ class ClinicGroupPermuterTest(TestCase):
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 30a6763..a8687e3 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()