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] [day] [month] [year] [list]
Message-ID: <20250709174440.39b0f49e@sal.lan>
Date: Wed, 9 Jul 2025 17:44:40 +0200
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To: Donald Hunter <donald.hunter@...il.com>
Cc: Linux Doc Mailing List <linux-doc@...r.kernel.org>, Jonathan Corbet
 <corbet@....net>, "Akira Yokosawa" <akiyks@...il.com>, "Breno Leitao"
 <leitao@...ian.org>, "David S. Miller" <davem@...emloft.net>, "Eric
 Dumazet" <edumazet@...gle.com>, "Ignacio Encinas Rubio"
 <ignacio@...cinas.com>, "Jan Stancek" <jstancek@...hat.com>, "Marco Elver"
 <elver@...gle.com>, "Paolo Abeni" <pabeni@...hat.com>, "Randy Dunlap"
 <rdunlap@...radead.org>, "Ruben Wauters" <rubenru09@....com>, "Shuah Khan"
 <skhan@...uxfoundation.org>, joel@...lfernandes.org,
 linux-kernel-mentees@...ts.linux.dev, linux-kernel@...r.kernel.org,
 lkmm@...ts.linux.dev, netdev@...r.kernel.org, peterz@...radead.org,
 stern@...land.harvard.edu
Subject: Re: [PATCH v8 11/13] tools: netlink_yml_parser.py: add line numbers
 to parsed data

Em Fri, 27 Jun 2025 12:03:07 +0100
Donald Hunter <donald.hunter@...il.com> escreveu:

> Mauro Carvalho Chehab <mchehab+huawei@...nel.org> writes:
> 
> > When something goes wrong, we want Sphinx error to point to the
> > right line number from the original source, not from the
> > processed ReST data.
> >
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
> > ---
> >  tools/net/ynl/pyynl/lib/doc_generator.py | 34 ++++++++++++++++++++++--
> >  1 file changed, 32 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/net/ynl/pyynl/lib/doc_generator.py b/tools/net/ynl/pyynl/lib/doc_generator.py
> > index 866551726723..a9d8ab6f2639 100644
> > --- a/tools/net/ynl/pyynl/lib/doc_generator.py
> > +++ b/tools/net/ynl/pyynl/lib/doc_generator.py
> > @@ -20,6 +20,16 @@
> >  from typing import Any, Dict, List
> >  import yaml
> >  
> > +LINE_STR = '__lineno__'
> > +
> > +class NumberedSafeLoader(yaml.SafeLoader):
> > +    """Override the SafeLoader class to add line number to parsed data"""
> > +
> > +    def construct_mapping(self, node):
> > +        mapping = super().construct_mapping(node)
> > +        mapping[LINE_STR] = node.start_mark.line
> > +
> > +        return mapping  
> 
> pylint gives these 2 warnings:
> 
> tools/net/ynl/pyynl/lib/doc_generator.py:25:0: R0901: Too many ancestors (9/7) (too-many-ancestors)

I'm yet to find any pylint Rxxx warning that I didn't have to
disable ;-)

This particular one is useless for us, as it basically tells that PyYAML
has a big class hierarchy.

> tools/net/ynl/pyynl/lib/doc_generator.py:28:4: W0221: Number of parameters was 3 in 'SafeConstructor.construct_mapping' and is now 2 in overriding 'NumberedSafeLoader.construct_mapping' method (arguments-differ)

I'll fix this one to prevent potential future issues.

Changing the code to:
 
-class NumberedSafeLoader(yaml.SafeLoader):
+class NumberedSafeLoader(yaml.SafeLoader):              # pylint: disable=R0901
     """Override the SafeLoader class to add line number to parsed data"""
 
-    def construct_mapping(self, node):
-        mapping = super().construct_mapping(node)
+    def construct_mapping(self, node, *args, **kwargs):
+        mapping = super().construct_mapping(node, *args, **kwargs)
         mapping[LINE_STR] = node.start_mark.line
 
         return mapping

This should hopefully be future-proof.

Regards,
Mauro



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ