From: richard.purdie@linuxfoundation.org
To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>,
"bitbake-devel@lists.openembedded.org"
<bitbake-devel@lists.openembedded.org>
Subject: Re: [PATCH 2/3] data_smart: Allow numeric characters in overrides
Date: Tue, 18 Dec 2018 21:16:48 +0000 [thread overview]
Message-ID: <eae945fea01f12c8abd559b4988ae34f9e2fe405.camel@linuxfoundation.org> (raw)
In-Reply-To: <ca187ac1c83d43b282db6b8d66d416a8@XBOX04.axis.com>
On Tue, 2018-12-18 at 21:05 +0000, Peter Kjellerstedt wrote:
> I do not understand this commit. The commit explanation and the code change
> don't match up. The motivation in the commit message is that there was
> problems with overrides such as x86-64 containing digits and that the
> code should be changed to allow overrides to be lower case and numeric.
> However, the modified code changes the test from using islower(), which as
> far as I can tell only validates the alpha-characters in the string and
> ignores all else, to using a regular expression r'[a-z0-9]+', which will
> match as long as the first character is a lower case character or a numeric
> character (note that there is no $ at the end of the regular expression).
>
> Here are tests with islower(), which correctly validates "x86" and
> "x86-64"
> as lower case overrides, but not "fooBar":
>
> > > > "x86".islower()
> True
> > > > "x86-64".islower()
> True
> > > > "fooBar".islower()
> False
>
> Here are the corresponding tests using the r'[a-z0-9]+' regular
> expression.
> Note that it only matches "x86" from "x86-64" and "foo" from
> "fooBar", and
> will incorrectly allow "fooBar" as an override:
>
> > > > re.match(r'[a-z0-9]+', "x86")
> <_sre.SRE_Match object; span=(0, 3), match='x86'>
> > > > re.match(r'[a-z0-9]+', "x86-64")
> <_sre.SRE_Match object; span=(0, 3), match='x86'>
> > > > re.match(r'[a-z0-9]+', "fooBar")
> <_sre.SRE_Match object; span=(0, 3), match='foo'>
>
> So why change from islower(), which as far as I can tell did the
> right thing from the beginning?
The commit is clearly wrong. The intent of the commit message is
correct, it doesn't match what that regex actually does :(
Cheers,
Richard
next prev parent reply other threads:[~2018-12-18 21:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-14 14:02 [PATCH 1/3] data_smart: Add missing regexp markup Richard Purdie
2018-12-14 14:02 ` [PATCH 2/3] data_smart: Allow numeric characters in overrides Richard Purdie
2018-12-18 21:05 ` Peter Kjellerstedt
2018-12-18 21:16 ` richard.purdie [this message]
2018-12-19 10:55 ` Peter Kjellerstedt
2018-12-19 11:42 ` richard.purdie
2018-12-19 16:12 ` Peter Kjellerstedt
2018-12-19 19:59 ` richard.purdie
2018-12-14 14:02 ` [PATCH 3/3] utils: Add aarch64 support to ioprio_set Richard Purdie
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=eae945fea01f12c8abd559b4988ae34f9e2fe405.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=bitbake-devel@lists.openembedded.org \
--cc=peter.kjellerstedt@axis.com \
/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