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

Mike Frysinger <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <Y2ZzCE2C7dvDa7uN@vapier>
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
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmNmcwgACgkQQWM7n+g3
9YGLTQ//YgZ0Su6OZ66sJq+L4Kp1+4N3qal4AIjR6BqGtSuF9OW5pTaahqQCCWAh
s55IoxnzrH4bF9VYmeyoS4jO+CcJD9ZuwBBamKFo44vCRXJPmDtT2gQ5nn0LyUnR
M9UZIkfmQ6BwkIRLfhTfpnnghuDFTzsbkoWH+MVfVyGFER8d1E/RJ8o2ubYdacub
vvPR4SW2Fx8wHCrNek841Tffix1ZPK242G59+HtzvOqP3tW8wWDWbJ+8qPOidQcg
UkAjAbEGLaiqTp1kXRzPLsjsL+PnesZ9O+1Khg2ybPl1IEqyF0eve1AF2hUyM+pA
aRUSETc1mbNRPRHgphQ3WdBDtvIt5lcuLywi4tRHmDM1fNp8MvYtFjKpEALS+BzJ
XbUza2i3YG8+sBxD9dx/9qrqn0KNAv/WcO/8kT98CMJ7ygShLGpt5Rz2ZvYshWP3
CvMNN0CnJZGo+GQ3ZfQECax7PfKo+5U2CJDKkZkRb8ql7EELi8s7j2459KLlLTQi
qGYbHWCc0vf7ps2CYQRFnWSHBApqRIb7iR+VGhFOv5gi234YzJ7/Rqnln9+GrZSp
aTJ7nbc95s+wv3wyQy5cfNhyTQlRaZD9M4qU/d75IzKyz6DitRfs6/OvgC9iH/9J
P7UJy8gRAX/aztEj5mVNIGbBvVNdw/TvaU359TPhJni2i3XH0XA=
=xUBi
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.