Re: [PATCH] makedocbook: Fix false report of unhandled texinfo command

Mike Frysinger <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <Y1+/XcpYt7wSmD4v@vapier>
On 31 Oct 2022 09:59, Jon Turney wrote:

i guess the feedback below isn't exactly about new code even if it's relevant ...

> +    # fail if there are unhandled texinfo commands
> +    match = re.search('(?<!@)@[^@\s]+', s)

regexes should use raw strings (i.e., this is missing the r prefix)

> +    if match:
> +        print("texinfo command '%s' remains in output" % match.group(), file=sys.stderr)

this is a little dangerous in general as match.group() could return a tuple,
and this would fail.  if you want to use %, you should force a tuple.
  print("..." % (match.group(),), ...)

> +        exit(1)

scripts should never use exit(), only sys.exit().  although i see the current
script gets this wrong in a lot of places.

also you can simplify this -- sys.exit accepts a string that it'll print to
stderr and then exit non-zero.
  sys.exit(".....")
-mike
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmNfv10ACgkQQWM7n+g3
9YEyMA/+NDGIV1TmjSZvJMoF90jjMvZ4HLe9EWdw6xGnLNi0UBtdvARVYUlzMFIV
66eC1gmo0MclikIZ+6cniw1IsGbTWYPmR/kpxrOdPHUVOmARL3NO2czVEzr/9KOj
onNG53SzgJZsWyg/b8MOLWuoAi57QVD/qKNMAPq2VP6Dna06z3ccLmaVp+DSiEvA
S5RGxwkeccQ0yBUKN10vO02AIAjRV0ZRrZD6YiCebYwDn49yyrzFqkyiV5HkR5Yu
H8WC8A1/eumKTDrgWqJByIasxUOwbcaP9BkzWC2BAoawihGnIUBuzFgFPL4oDzwW
/aNKukKUshQ9qg6kgPbZNxedhYrH+FhxGC011LVoBv4NOKPMvrMyOPV9h1bDOYc9
nUXa0qP5HoHP7VDvcAbgR/5kDcZYlFV2JKSXsQH5gWj41oJtesoK+TR2Y+vJnajq
of+QBr2xUnDfW6XNKMioSR9EBqXzF/SmewU02Ar9+vWGuapYrjBN710Kx7tyP/WI
4yD5swi/pt5eiTJWm7orgVS6OyFUhVLwaXPj5NQRqF5p94lxBYB06d4LAsW2SmFJ
BWhnlq6JAzA4Svmxkabd5+DnD8pjItW+ZTi2zMIbKRTGcp9i1fFp3jxwtUwKdAG7
ufSfDsIAc98Hx6ZVUt5CIJEjEiKQ7FyLCA0915oEPLhE6WRrlZE=
=inXn
-----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.