public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: Mike Frysinger <vapier@gentoo.org>,
	"newlib@sourceware.org" <newlib@sourceware.org>
Subject: Re: [PATCH] makedocbook: Fix false report of unhandled texinfo command
Date: Fri, 4 Nov 2022 13:50:42 +0000	[thread overview]
Message-ID: <9b242eca-08ba-cc4f-fc2c-b8ad72992c37@dronecode.org.uk> (raw)
In-Reply-To: <Y1+/XcpYt7wSmD4v@vapier>

On 31/10/2022 12:28, Mike Frysinger wrote:
> 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(),), ...)

I must be missing something here, because I'm not sure in what sense 
'could' is being used. I think match.group() is defined to be the same 
as match.group(0), which always returns a single string. (I guess this 
could be written explicitly).

So the danger pointed out seems to be that if parts of the code were 
changed, without making other necessary changes, it would be wrong. But 
I'm not sure the suggested change just to avoid that future possibility 
makes things better or clearer.

> 
>> +        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(".....")

Yes, this is one of the first things I wrote in python, and 
unfortunately, it shows.

I've posted a revised patch-set.


  reply	other threads:[~2022-11-04 13:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31  9:59 Jon Turney
2022-10-31 12:28 ` Mike Frysinger
2022-11-04 13:50   ` Jon Turney [this message]
2022-11-04 15:13     ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9b242eca-08ba-cc4f-fc2c-b8ad72992c37@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=newlib@sourceware.org \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).