Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scripts: kdoc: make it backward-compatible with Python 3.7

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

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
39e39af7 7740f9db

+3 -1
+3 -1
scripts/lib/kdoc/kdoc_parser.py
··· 1120 1120 # Found an export, trim out any special suffixes 1121 1121 # 1122 1122 for suffix in suffixes: 1123 - symbol = symbol.removesuffix(suffix) 1123 + # Be backward compatible with Python < 3.9 1124 + if symbol.endswith(suffix): 1125 + symbol = symbol[:-len(suffix)] 1124 1126 function_set.add(symbol) 1125 1127 return True 1126 1128