Skip to contentSkip to conversation

data_smart: Add missing regexp markup

PATCH In review Richard Purdie 2 participants 9 messages Dec 14, 2018 – Dec 19, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 data_smart: Add missing regexp markup

Fix some further python3 warnings about unescaped regexs.

---
 lib/bb/data_smart.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/data_smart.py +2 -2
index 67af38050e..297a2f45b4 100644
@@ -39,10 +39,10 @@ from bb.COW  import COWDictBase
 logger = logging.getLogger("BitBake.Data")
 
 __setvar_keyword__ = ["_append", "_prepend", "_remove"]
-__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend|_remove)(_(?P<add>[^A-Z]*))?$')
+__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>_append|_prepend|_remove)(_(?P<add>[^A-Z]*))?$')
 __expand_var_regexp__ = re.compile(r"\${[^{}@\n\t :]+}")
 __expand_python_regexp__ = re.compile(r"\${@.+?}")
-__whitespace_split__ = re.compile('(\s)')
+__whitespace_split__ = re.compile(r'(\s)')
 
 def infer_caller_details(loginfo, parent = False, varval = True):
     """Save the caller the trouble of specifying everything."""
Signature · 1 line
2.19.1
#1 lore raw

PATCH 2/3 data_smart: Allow numeric characters in overrides

We're seeing problems due to the way x86-64 is handled (or not handled) as an override. Relax the containts on overrides from being lowercase to being lowercase or numeric. This fixes problem where MACHINE=qemux86 would work but MACHINE=qemux86-64 would fail the same tests.

---
 lib/bb/data_smart.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/data_smart.py +2 -1
index 297a2f45b4..c342adaa0a 100644
@@ -43,6 +43,7 @@ __setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>_append|_prepend|_remo
 __expand_var_regexp__ = re.compile(r"\${[^{}@\n\t :]+}")
 __expand_python_regexp__ = re.compile(r"\${@.+?}")
 __whitespace_split__ = re.compile(r'(\s)')
+__override_regexp__ = re.compile(r'[a-z0-9]+')
 
 def infer_caller_details(loginfo, parent = False, varval = True):
     """Save the caller the trouble of specifying everything."""
@@ -597,7 +598,7 @@ class DataSmart(MutableMapping):
         # aka pay the cookie monster
         override = var[var.rfind('_')+1:]
         shortvar = var[:var.rfind('_')]
-        while override and override.islower():
+        while override and __override_regexp__.match(override):
             if shortvar not in self.overridedata:
                 self.overridedata[shortvar] = []
             if [var, override] not in self.overridedata[shortvar]:
Signature · 1 line
2.19.1
#2 lore raw

Re: [PATCH 2/3] data_smart: Allow numeric characters in overrides

Quoted 41 lines

-----Original Message-----
From: [email protected] <bitbake-devel- [email protected]> On Behalf Of Richard Purdie
Sent: den 14 december 2018 15:02
To: [email protected]
Subject: [bitbake-devel] [PATCH 2/3] data_smart: Allow numeric characters in overrides

We're seeing problems due to the way x86-64 is handled (or not handled) as an override. Relax the containts on overrides from being lowercase to being lowercase or numeric. This fixes problem where MACHINE=qemux86 would work but MACHINE=qemux86-64 would fail the same tests.

---
 lib/bb/data_smart.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/data_smart.py +0 -0
index 297a2f45b4..c342adaa0a 100644
@@ -43,6 +43,7 @@ __setvar_regexp__ =

re.compile(r'(?P<base>.*?)(?P<keyword>_append|_prepend|_remo
__expand_var_regexp__ = re.compile(r"\${[^{}@\n\t :]+}") __expand_python_regexp__ = re.compile(r"\${@.+?}") __whitespace_split__ = re.compile(r'(\s)')

lib/bb/data_smart.py +2 -2
+__override_regexp__ = re.compile(r'[a-z0-9]+')
 
 def infer_caller_details(loginfo, parent = False, varval = True):
     """Save the caller the trouble of specifying everything."""
@@ -597,7 +598,7 @@ class DataSmart(MutableMapping):
         # aka pay the cookie monster
         override = var[var.rfind('_')+1:]
         shortvar = var[:var.rfind('_')]
-        while override and override.islower():
+        while override and __override_regexp__.match(override):
             if shortvar not in self.overridedata:
                 self.overridedata[shortvar] = []
             if [var, override] not in self.overridedata[shortvar]:
--
Quoted 1 line

2.19.1

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":

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x86".islower()

True

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x86-64".islower()

True

Quoted 1 line
Quoted 1 line
Quoted 1 line

"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:

Quoted 1 line
Quoted 1 line
Quoted 1 line

re.match(r'[a-z0-9]+', "x86")

<_sre.SRE_Match object; span=(0, 3), match='x86'>

Quoted 1 line
Quoted 1 line
Quoted 1 line

re.match(r'[a-z0-9]+', "x86-64")

<_sre.SRE_Match object; span=(0, 3), match='x86'>

Quoted 1 line
Quoted 1 line
Quoted 1 line

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?

//Peter

#3 lore raw

Re: [PATCH 2/3] data_smart: Allow numeric characters in overrides

Quoted 28 lines · Peter Kjellerstedt

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":

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x86".islower()

True

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x86-64".islower()

True

Quoted 1 line
Quoted 1 line
Quoted 1 line

"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:

Quoted 1 line
Quoted 1 line
Quoted 1 line

re.match(r'[a-z0-9]+', "x86")

Quoted 8 lines

<_sre.SRE_Match object; span=(0, 3), match='x86'>

Quoted 1 line
Quoted 1 line
Quoted 1 line

re.match(r'[a-z0-9]+', "x86-64")

<_sre.SRE_Match object; span=(0, 3), match='x86'>

Quoted 1 line
Quoted 1 line
Quoted 1 line

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

#4 lore raw

Re: [PATCH 2/3] data_smart: Allow numeric characters in overrides

Quoted 55 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: den 18 december 2018 22:17
To: Peter Kjellerstedt <[email protected]>; bitbake- [email protected]
Subject: Re: [bitbake-devel] [PATCH 2/3] data_smart: Allow numeric characters in overrides

Quoted 1 line · Peter Kjellerstedt

I do not understand this commit. The commit explanation and the code

change

Quoted 1 line

don't match up. The motivation in the commit message is that there

was

Quoted 2 lines

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.

Quoted 1 line

However, the modified code changes the test from using islower(),

which as

Quoted 1 line

far as I can tell only validates the alpha-characters in the string

and

Quoted 1 line

ignores all else, to using a regular expression r'[a-z0-9]+', which

will

Quoted 1 line

match as long as the first character is a lower case character or a

numeric

Quoted 1 line

character (note that there is no $ at the end of the regular

expression).

Quoted 19 lines

Here are tests with islower(), which correctly validates "x86" and "x86-64"
as lower case overrides, but not "fooBar":

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x86".islower()

True

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x86-64".islower()

True

Quoted 1 line
Quoted 1 line
Quoted 1 line

"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:

Quoted 1 line
Quoted 1 line
Quoted 1 line

re.match(r'[a-z0-9]+', "x86")

Quoted 8 lines

<_sre.SRE_Match object; span=(0, 3), match='x86'>

Quoted 1 line
Quoted 1 line
Quoted 1 line

re.match(r'[a-z0-9]+', "x86-64")

<_sre.SRE_Match object; span=(0, 3), match='x86'>

Quoted 1 line
Quoted 1 line
Quoted 1 line

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?

Quoted 6 lines

The commit is clearly wrong. The intent of the commit message is correct, it doesn't match what that regex actually does :(

Cheers,

Richard

I don't understand the commit message either. It says that there are problems with x86-64 because it contains digits, but x86 (which the commit message says works) contains digits too, so that cannot really be the case. If it is actually the dash in x86-64 that is supposedly a cause of problems, then islower() ignores both digits and non-alpha characters like the dash so that cannot really be a reason to change the code either. All in all I'm confused by this commit and what it is trying to solve...

//Peter

#5 lore raw

Re: [PATCH 2/3] data_smart: Allow numeric characters in overrides

Quoted 10 lines · Peter Kjellerstedt

I don't understand the commit message either. It says that there are problems with x86-64 because it contains digits, but x86 (which the commit message says works) contains digits too, so that cannot really
be the case. If it is actually the dash in x86-64 that is supposedly a cause of problems, then islower() ignores both digits and non- alpha
characters like the dash so that cannot really be a reason to change the code either. All in all I'm confused by this commit and what it is trying to solve...

Consider this output from python:

Quoted 1 line
Quoted 1 line
Quoted 1 line

"64".islower()

False

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x64".islower()

True

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x64A".islower()

False

Quoted 1 line
Quoted 1 line
Quoted 1 line

The problem is that "64".islower() returns False when we need True (overrides get split by '_' so x86_64 turns into "x86" and "64" in the code in question).

Cheers,

Richard

#6 lore raw

Re: [PATCH 2/3] data_smart: Allow numeric characters in overrides

Quoted 31 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: den 19 december 2018 12:42
To: Peter Kjellerstedt <[email protected]>; bitbake- [email protected]
Subject: Re: [bitbake-devel] [PATCH 2/3] data_smart: Allow numeric characters in overrides

Quoted 10 lines · Peter Kjellerstedt

I don't understand the commit message either. It says that there are problems with x86-64 because it contains digits, but x86 (which the commit message says works) contains digits too, so that cannot really
be the case. If it is actually the dash in x86-64 that is supposedly a cause of problems, then islower() ignores both digits and non- alpha
characters like the dash so that cannot really be a reason to change the code either. All in all I'm confused by this commit and what it is trying to solve...

Consider this output from python:

Quoted 1 line
Quoted 1 line
Quoted 1 line

"64".islower()

False

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x64".islower()

True

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x64A".islower()

False

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines

The problem is that "64".islower() returns False when we need True (overrides get split by '_' so x86_64 turns into "x86" and "64" in the code in question).

Cheers,

Richard

Ok, that makes more sense, except for one thing: where/when is _x86_64 used as override(s)? The only related overrides I can find in OE-Core all use _x86-64, which matches ${TRANSLATED_TARGET_ARCH} for, e.g., qemux86-64.

//Peter

#7 lore raw

Re: [PATCH 2/3] data_smart: Allow numeric characters in overrides

Quoted 40 lines · Peter Kjellerstedt
Quoted 40 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: den 19 december 2018 12:42
To: Peter Kjellerstedt <[email protected]>; bitbake- [email protected]
Subject: Re: [bitbake-devel] [PATCH 2/3] data_smart: Allow numeric characters in overrides

Quoted 7 lines · Peter Kjellerstedt

I don't understand the commit message either. It says that there are
problems with x86-64 because it contains digits, but x86 (which the
commit message says works) contains digits too, so that cannot really
be the case. If it is actually the dash in x86-64 that is

Quoted 8 lines

supposedly
a cause of problems, then islower() ignores both digits and non- alpha
characters like the dash so that cannot really be a reason to change
the code either. All in all I'm confused by this commit and what it
is trying to solve...

Consider this output from python:

Quoted 1 line
Quoted 1 line
Quoted 1 line

"64".islower()

False

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x64".islower()

True

Quoted 1 line
Quoted 1 line
Quoted 1 line

"x64A".islower()

False

The problem is that "64".islower() returns False when we need True (overrides get split by '_' so x86_64 turns into "x86" and "64" in the
code in question).

Quoted 8 lines
Quoted 3 lines

Cheers,

Richard

Ok, that makes more sense, except for one thing: where/when is _x86_64 used as override(s)? The only related overrides I can find in OE-Core all use _x86-64, which matches ${TRANSLATED_TARGET_ARCH} for, e.g., qemux86-64.

Its not obvious as its indirect:

conf/distro/include/maintainers.inc:RECIPE_MAINTAINER_pn-gcc-cross-${TARGET_ARCH} = "Khem Raj <[email protected]>"

That worked for MACHINE=qemux86 but not for MACHINE=qemux86-64.

Arguably you could rename that to use TRANSLATED_TARGET_ARCH but I seem to remember there were others which would have been harder to rename out of.

We should add some testcases to bitbake-selftest for this.

Cheers,

Richard

#8 lore raw

PATCH 3/3 utils: Add aarch64 support to ioprio_set

In reply to Richard Purdie

With aarch64 hosts coming into use, set the syscall number to avoid ioprio warnings on that platform.

---
 lib/bb/utils.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/utils.py +2 -0
index f687ee4127..9cb702dbb7 100644
@@ -1497,6 +1497,8 @@ def ioprio_set(who, cls, value):
       NR_ioprio_set = 251
     elif _unamearch[0] == "i" and _unamearch[2:3] == "86":
       NR_ioprio_set = 289
+    elif _unamearch == "aarch64":
+      NR_ioprio_set = 30
 
     if NR_ioprio_set:
         ioprio = value | (cls << IOPRIO_CLASS_SHIFT)
Signature · 1 line
2.19.1