lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250129150615.1c256acb@foz.lan>
Date: Wed, 29 Jan 2025 15:06:15 +0100
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To: Akira Yokosawa <akiyks@...il.com>
Cc: corbet@....net, gregkh@...uxfoundation.org, linux-doc@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [RFC v2 17/38] scripts/get_abi.py: use an interactor for ReST
 output

Em Wed, 29 Jan 2025 20:04:42 +0900
Akira Yokosawa <akiyks@...il.com> escreveu:

> Hi,
> 
> Mauro Carvalho Chehab wrote:
> 
> > Instead of printing all results line per line, use an interactor
> > to return each variable as a separate message.
> > 
> > This won't change much when using it via command line, but it
> > will help Sphinx integration by providing an interactor that
> > could be used there to handle ABI symbol by symbol.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
> > ---
> >  scripts/get_abi.py | 52 ++++++++++++++++++++++++++--------------------
> >  1 file changed, 29 insertions(+), 23 deletions(-)
> > 
> > diff --git a/scripts/get_abi.py b/scripts/get_abi.py
> > index 73613fb29c1c..2aec1f9dc5aa 100755
> > --- a/scripts/get_abi.py
> > +++ b/scripts/get_abi.py  
> [...]
> > @@ -470,9 +472,9 @@ class AbiParser:
> >  
> >                  if cur_part and cur_part != part:
> >                      part = cur_part
> > -                    print(f"{part}\n{"-" * len(part)}\n")
> > +                    msg += f"{part}\n{"-" * len(part)}\n\n"
> >  
> > -                print(f".. _{key}:\n")
> > +                msg += f".. _{key}:\n\n"
> >  
> >                  max_len = 0
> >                  for i in range(0, len(names)):           # pylint: disable=C0200  
> [...]
> 
> Testing under Ubuntu 22.04, where distro python3 is 3.10.12 and
> distro Sphinx is 4.3.2, I get this exception by running "make htmldocs":
> 
> Exception occurred:
>   File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
>     from get_abi import AbiParser
>   File ".../linux/scripts/get_abi.py", line 525
>     msg += f"{part}\n{"-" * len(part)}\n\n"
>                        ^
> SyntaxError: f-string: expecting '}'
> 
> , which is introduced in the above hunk, I guess.
> 
> You can install Sphinx 8.1.3 on top of python3 3.10.12 using venv.
> I get the same exception there.
> 
> Your change works fine against Ubuntu 24.04, whose distro python3 is 3.12.3.
> 
> I have not tested against python3 3.11.x.
> 
> It would be better to keep compatible with >= python 3.10.x if at all
> possible.

Thanks for checking it!

I was aiming to make it compatible with 3.6. Yet, it seems that f-string
support is very limited on early versions. The enclosed diff will make
it backward-compatible with Python 3.6.

Thanks,
Mauro

diff --git a/scripts/get_abi.py b/scripts/get_abi.py
index 543bed397c8c..e6e94f721fff 100755
--- a/scripts/get_abi.py
+++ b/scripts/get_abi.py
@@ -522,7 +522,7 @@ class AbiParser:
 
                 if cur_part and cur_part != part:
                     part = cur_part
-                    msg += f"{part}\n{"-" * len(part)}\n\n"
+                    msg += part + "\n"+ "-" * len(part) +"\n\n"
 
                 msg += f".. _{key}:\n\n"
 
@@ -546,7 +546,7 @@ class AbiParser:
                     msg += f"Defined on file :ref:`{base} <{ref[1]}>`\n\n"
 
             if wtype == "File":
-                msg += f"{names[0]}\n{"-" * len(names[0])}\n\n"
+                msg += names[0] +"\n" + "-" * len(names[0]) +"\n\n"
 
             desc = v.get("description")
             if not desc and wtype != "File":
@@ -570,7 +570,8 @@ class AbiParser:
 
             users = v.get("users")
             if users and users.strip(" \t\n"):
-                msg += f"Users:\n\t{users.strip("\n").replace('\n', '\n\t')}\n\n"
+                users = users.strip("\n").replace('\n', '\n\t')
+                msg += f"Users:\n\t{users}\n\n"
 
             ln = v.get("line_no", 1)
 
@@ -596,7 +597,9 @@ class AbiParser:
                 elif len(lines) == 1:
                     f.append(f"{fname}:{lines[0]}")
                 else:
-                    f.append(f"{fname} lines {", ".join(str(x) for x in lines)}")
+                    m = fname + "lines "
+                    m += ", ".join(str(x) for x in lines)
+                    f.append(m)
 
             self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f))
 
@@ -644,10 +647,11 @@ class AbiParser:
                     if users:
                         print(f"Users:\t\t\t{users}")
 
-                    print(f"Defined on file{'s'[:len(files) ^ 1]}:\t{", ".join(files)}")
+                    print("Defined on file(s):\t" + ", ".join(files))
 
                     if desc:
-                        print(f"\n{desc.strip("\n")}\n")
+                        desc = desc.strip("\n")
+                        print(f"\n{desc}\n")
 
         if not found_keys:
             print(f"Regular expression /{expr}/ not found.")


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ