[PATCH 2/5] makedocbook: Use sys.exit()

Mike Frysinger vapier@gentoo.org
Sat Nov 5 14:28:24 GMT 2022


On 04 Nov 2022 15:52, Torbjorn SVENSSON wrote:
> On 2022-11-04 14:49, Jon Turney wrote:
> > Use sys.exit() to write a message to stderr and terminate with a
> > non-zero exit code.
> > ---
> >   newlib/doc/makedocbook.py | 16 ++++++----------
> >   1 file changed, 6 insertions(+), 10 deletions(-)
> > 
> > diff --git a/newlib/doc/makedocbook.py b/newlib/doc/makedocbook.py
> > index 5e46082df..57cd23bfd 100755
> > --- a/newlib/doc/makedocbook.py
> > +++ b/newlib/doc/makedocbook.py
> > @@ -214,8 +214,7 @@ def function(c, l):
> >   
> >       # FUNCTION implies starting a new refentry
> >       if refentry is not None:
> > -        print("multiple FUNCTIONs without NEWPAGE", file=sys.stderr)
> > -        exit(1)
> > +        sys.exit("multiple FUNCTIONs without NEWPAGE")
> >   
> >       # create the refentry
> >       refentry = lxml.etree.SubElement(rootelement, 'refentry')
> > @@ -308,17 +307,15 @@ def synopsis(c, t):
> >   
> >               # a prototype without a terminating ';' is an error
> >               if s.endswith(')'):
> > -                print("'%s' missing terminating semicolon" % l, file=sys.stderr)
> > +                sys.exit("'%s' missing terminating semicolon" % l)
> 
> I'm not sure when it was introduced in python, but you can use this syntax:
> sys.exit(f"'{l}' missing terminating semicolon")

f-strings are new to Python 3.6.  i don't know what version we want to
require when building from git (non-releases).  other GNU toolchain
projects seem to be OK with requiring newer versions like 3.6.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20221105/914a3cb2/attachment.sig>


More information about the Newlib mailing list