Skip to content

Commit 78ea748

Browse files
mchehabJonathan Corbet
authored andcommitted
scripts/lib/kdoc/kdoc_parser.py: fix Python compat with < v3.13
- str.replace count was introduced only in Python 3.13; - before Python 3.13, f-string dict arguments can't use the same delimiter of the main string. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/e2b8e8361294558dae09236e4b8fbea5d86be5a3.1744106242.git.mchehab+huawei@kernel.org
1 parent 485f6f7 commit 78ea748

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

scripts/lib/kdoc/kdoc_output.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,16 +647,16 @@ def out_function(self, fname, name, args):
647647
sectionlist = args.get('sectionlist', [])
648648
sections = args.get('sections', {})
649649

650-
self.data += f'.TH "{args['function']}" 9 "{args['function']}" "{self.man_date}" "Kernel Hacker\'s Manual" LINUX' + "\n"
650+
self.data += f'.TH "{args["function"]}" 9 "{args["function"]}" "{self.man_date}" "Kernel Hacker\'s Manual" LINUX' + "\n"
651651

652652
self.data += ".SH NAME\n"
653653
self.data += f"{args['function']} \\- {args['purpose']}\n"
654654

655655
self.data += ".SH SYNOPSIS\n"
656656
if args.get('functiontype', ''):
657-
self.data += f'.B "{args['functiontype']}" {args['function']}' + "\n"
657+
self.data += f'.B "{args["functiontype"]}" {args["function"]}' + "\n"
658658
else:
659-
self.data += f'.B "{args['function']}' + "\n"
659+
self.data += f'.B "{args["function"]}' + "\n"
660660

661661
count = 0
662662
parenth = "("
@@ -697,7 +697,7 @@ def out_enum(self, fname, name, args):
697697
sectionlist = args.get('sectionlist', [])
698698
sections = args.get('sections', {})
699699

700-
self.data += f'.TH "{args['module']}" 9 "enum {args['enum']}" "{self.man_date}" "API Manual" LINUX' + "\n"
700+
self.data += f'.TH "{args["module"]}" 9 "enum {args["enum"]}" "{self.man_date}" "API Manual" LINUX' + "\n"
701701

702702
self.data += ".SH NAME\n"
703703
self.data += f"enum {args['enum']} \\- {args['purpose']}\n"

scripts/lib/kdoc/kdoc_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,9 @@ def syscall_munge(self, ln, proto): # pylint: disable=W0613
14441444

14451445
r = Re(r'long\s+(sys_.*?),')
14461446
if r.search(proto):
1447-
proto = proto.replace(',', '(', count=1)
1447+
proto = Re(',').sub('(', proto, count=1)
14481448
elif is_void:
1449-
proto = proto.replace(')', '(void)', count=1)
1449+
proto = Re(r'\)').sub('(void)', proto, count=1)
14501450

14511451
# Now delete all of the odd-numbered commas in the proto
14521452
# so that argument types & names don't have a comma between them

0 commit comments

Comments
 (0)