From 02299dcd203c55d12238c95f1d028f06b90f1c1e Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Fri, 7 Aug 2026 15:10:03 -0700 Subject: docs: python: abi_regex: catch the right exception for a bad regex While validating recent CXL ABI documentation updates with get_abi.py, the 'undefined' mode was found to abort instead of reporting undocumented ABI entries. Older Python releases raise re.error, while newer releases expose re.PatternError. Catching the compatible re.error exception handles both cases. Use re.error so the scan continues and reports the remaining results. Signed-off-by: Alison Schofield Signed-off-by: Jonathan Corbet Message-ID: <9f6fa7a9aa6ba9a26b484b911976713356b3fd44.1786139549.git.alison.schofield@intel.com> --- tools/lib/python/abi/abi_regex.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tools/lib/python/abi') diff --git a/tools/lib/python/abi/abi_regex.py b/tools/lib/python/abi/abi_regex.py index d0c5e3ede6b5..69d8507b7382 100644 --- a/tools/lib/python/abi/abi_regex.py +++ b/tools/lib/python/abi/abi_regex.py @@ -155,7 +155,7 @@ class AbiRegex(AbiParser): if self.search_string: if what.find(self.search_string) >= 0: print(f"What: {what}") - except re.PatternError: + except re.error: self.log.warning("Ignoring '%s' as it produced an invalid regex:\n" " '%s'", what, new) @@ -194,7 +194,7 @@ class AbiRegex(AbiParser): try: self.re_string = re.compile(self.search_string) - except re.PatternError as e: + except re.error as e: msg = f"{self.search_string} is not a valid regular expression" raise ValueError(msg) from e @@ -223,9 +223,9 @@ class AbiRegex(AbiParser): for r, s in self.re_whats: try: new = r.sub(s, new) - except re.PatternError as e: + except re.error as e: # Help debugging troubles with new regexes - raise re.PatternError(f"{e}\nwhile re.sub('{r.pattern}', {s}, str)") from e + raise re.error(f"{e}\nwhile re.sub('{r.pattern}', {s}, str)") from e v["regex"].append(new) -- cgit v1.2.3 From 47646ce123fbd07d7c4d8052831c35f58ffcd074 Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Fri, 7 Aug 2026 15:10:04 -0700 Subject: docs: python: abi_regex: convert adjacent index placeholders While validating recent CXL ABI documentation updates with get_abi.py, every decoderX.Y entry was reported as undocumented. The placeholder conversion mishandles adjacent index placeholders, producing patterns that cannot match the corresponding sysfs paths. As a result, valid ABI entries are reported as undocumented. Handle adjacent placeholders independently so generated patterns match the documented paths. This fixes decoderX.Y entries in the CXL ABI and other ABI documentation that uses the same naming convention. Signed-off-by: Alison Schofield Signed-off-by: Jonathan Corbet Message-ID: --- tools/lib/python/abi/abi_regex.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tools/lib/python/abi') diff --git a/tools/lib/python/abi/abi_regex.py b/tools/lib/python/abi/abi_regex.py index 69d8507b7382..198ecbf49c51 100644 --- a/tools/lib/python/abi/abi_regex.py +++ b/tools/lib/python/abi/abi_regex.py @@ -65,8 +65,7 @@ class AbiRegex(AbiParser): (re.compile(r"\[[^\]]+\]"), "\\\\w\xf7"), (re.compile(r"XX+"), "\\\\w\xf7"), - (re.compile(r"([^A-Z])[XYZ]([^A-Z])"), "\\1\\\\w\xf7\\2"), - (re.compile(r"([^A-Z])[XYZ]$"), "\\1\\\\w\xf7"), + (re.compile(r"(?