]> www.infradead.org Git - users/griffoul/linux.git/commitdiff
scripts: kdoc: make it backward-compatible with Python 3.7
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 11 Jul 2025 07:27:09 +0000 (09:27 +0200)
committerJonathan Corbet <corbet@lwn.net>
Thu, 17 Jul 2025 21:29:53 +0000 (15:29 -0600)
There was a change at kdoc that ended breaking compatibility
with Python 3.7: str.removesuffix() was introduced on version
3.9.

Restore backward compatibility.

Reported-by: Akira Yokosawa <akiyks@gmail.com>
Closes: https://lore.kernel.org/linux-doc/57be9f77-9a94-4cde-aacb-184cae111506@gmail.com/
Fixes: 27ad33b6b349 ("kernel-doc: Fix symbol matching for dropped suffixes")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/d13058d285838ac2bc04c492e60531c013a8a919.1752218291.git.mchehab+huawei@kernel.org
scripts/lib/kdoc/kdoc_parser.py

index 06f55f38d4a707379fd6a083f8f7afd9280bc1f3..c3fe4bd5eab4b6ed0885dc21d4e09ce1c52e1322 100644 (file)
@@ -1120,7 +1120,9 @@ class KernelDoc:
         # Found an export, trim out any special suffixes
         #
         for suffix in suffixes:
-            symbol = symbol.removesuffix(suffix)
+            # Be backward compatible with Python < 3.9
+            if symbol.endswith(suffix):
+                symbol = symbol[:-len(suffix)]
         function_set.add(symbol)
         return True