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

Configure Feed

Select the types of activity you want to include in your feed.

scripts/lib/abi/abi_parser.py: make it backward-compatible with Python 3.6

Despite being introduced on Python 3.6, the original implementation
was too limited: it doesn't accept anything but the argument.

Even on python 3.10.12, support was still limited, as more complex
operations cause SyntaxError:

Exception occurred:
File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
from get_abi import AbiParser
File ".../linux/scripts/lib/abi/abi_parser.py", line 525
msg += f"{part}\n{"-" * len(part)}\n\n"
^
SyntaxError: f-string: expecting '}'

Replace f-strings by normal string concatenation when it doesn't
work on Python 3.6.

Reported-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/41d2f85df134a46db46fed73a0f9697a3d2ae9ba.1739182025.git.mchehab+huawei@kernel.org

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
6649b421 dc525a76

+10 -6
+10 -6
scripts/lib/abi/abi_parser.py
··· 493 493 494 494 if cur_part and cur_part != part: 495 495 part = cur_part 496 - msg += f"{part}\n{"-" * len(part)}\n\n" 496 + msg += part + "\n"+ "-" * len(part) +"\n\n" 497 497 498 498 msg += f".. _{key}:\n\n" 499 499 ··· 517 517 msg += f"Defined on file :ref:`{base} <{ref[1]}>`\n\n" 518 518 519 519 if wtype == "File": 520 - msg += f"{names[0]}\n{"-" * len(names[0])}\n\n" 520 + msg += names[0] +"\n" + "-" * len(names[0]) +"\n\n" 521 521 522 522 desc = v.get("description") 523 523 if not desc and wtype != "File": ··· 541 541 542 542 users = v.get("users") 543 543 if users and users.strip(" \t\n"): 544 - msg += f"Users:\n\t{users.strip("\n").replace('\n', '\n\t')}\n\n" 544 + users = users.strip("\n").replace('\n', '\n\t') 545 + msg += f"Users:\n\t{users}\n\n" 545 546 546 547 ln = v.get("line_no", 1) 547 548 ··· 568 567 elif len(lines) == 1: 569 568 f.append(f"{fname}:{lines[0]}") 570 569 else: 571 - f.append(f"{fname} lines {", ".join(str(x) for x in lines)}") 570 + m = fname + "lines " 571 + m += ", ".join(str(x) for x in lines) 572 + f.append(m) 572 573 573 574 self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f)) 574 575 ··· 618 615 if users: 619 616 print(f"Users:\t\t\t{users}") 620 617 621 - print(f"Defined on file{'s'[:len(files) ^ 1]}:\t{", ".join(files)}") 618 + print("Defined on file(s):\t" + ", ".join(files)) 622 619 623 620 if desc: 624 - print(f"\n{desc.strip("\n")}\n") 621 + desc = desc.strip("\n") 622 + print(f"\n{desc}\n") 625 623 626 624 if not found_keys: 627 625 print(f"Regular expression /{expr}/ not found.")