diff mbox series

[scarthgap,09/10] kern-tools-native: fix SyntaxWarning for RegEx calls on Python 3.12

Message ID fb0653a8b95be95eb2553b7c939444683cb11eed.1734553652.git.steve@sakoman.com
State Rejected
Delegated to: Steve Sakoman
Headers show
Series [scarthgap,01/10] binutils: Fix CVE-2024-53589 | expand

Commit Message

Steve Sakoman Dec. 18, 2024, 10:02 p.m. UTC
From: Hongxu Jia <hongxu.jia@windriver.com>

Python 3.12 emmits a SyntaxWarning when using unescaped
character inside a RegEx string.
'''
recipe-sysroot-native/usr/bin/symbol_why.py:161: SyntaxWarning: invalid escape sequence '\.'
  if re.match( ".*\.config", opt ):
recipe-sysroot-native/usr/bin/symbol_why.py:216: SyntaxWarning: invalid escape sequence '\w'
  x = re.match( "^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel Configuration", line )
recipe-sysroot-native/usr/bin/symbol_why.py:495: SyntaxWarning: invalid escape sequence '\s'
  if re.search( "^#\s*CONFIG_", option ):
'''

According to [1], use raw strings for regular expression

[1] https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 ...yntaxWarning-for-RegEx-calls-on-Pyth.patch | 60 +++++++++++++++++++
 .../kern-tools/kern-tools-native_git.bb       |  4 +-
 2 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch

Comments

Bruce Ashfield Dec. 19, 2024, 4:04 a.m. UTC | #1
Please don't take this patch in this format.

Once I've approved and merged the changes into the kern-tools, there will
be a SRCREV update.

So this is a NACK/

Bruce

On Wed, Dec 18, 2024 at 5:02 PM Steve Sakoman via lists.openembedded.org
<steve=sakoman.com@lists.openembedded.org> wrote:

> From: Hongxu Jia <hongxu.jia@windriver.com>
>
> Python 3.12 emmits a SyntaxWarning when using unescaped
> character inside a RegEx string.
> '''
> recipe-sysroot-native/usr/bin/symbol_why.py:161: SyntaxWarning: invalid
> escape sequence '\.'
>   if re.match( ".*\.config", opt ):
> recipe-sysroot-native/usr/bin/symbol_why.py:216: SyntaxWarning: invalid
> escape sequence '\w'
>   x = re.match( "^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel
> Configuration", line )
> recipe-sysroot-native/usr/bin/symbol_why.py:495: SyntaxWarning: invalid
> escape sequence '\s'
>   if re.search( "^#\s*CONFIG_", option ):
> '''
>
> According to [1], use raw strings for regular expression
>
> [1] https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> Signed-off-by: Steve Sakoman <steve@sakoman.com>
> ---
>  ...yntaxWarning-for-RegEx-calls-on-Pyth.patch | 60 +++++++++++++++++++
>  .../kern-tools/kern-tools-native_git.bb       |  4 +-
>  2 files changed, 63 insertions(+), 1 deletion(-)
>  create mode 100644
> meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch
>
> diff --git
> a/meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch
> b/meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch
> new file mode 100644
> index 0000000000..e87067c8ac
> --- /dev/null
> +++
> b/meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch
> @@ -0,0 +1,60 @@
> +From 1f64368e4e82e47cd0e0dfe37b0e1b8958566d21 Mon Sep 17 00:00:00 2001
> +From: Hongxu Jia <hongxu.jia@windriver.com>
> +Date: Tue, 17 Dec 2024 01:25:29 -0800
> +Subject: [PATCH] symbol_why: fix SyntaxWarning for RegEx calls on Python
> 3.12
> +
> +Python 3.12 emmits a SyntaxWarning when using unescaped
> +character inside a RegEx string.
> +'''
> +recipe-sysroot-native/usr/bin/symbol_why.py:161: SyntaxWarning: invalid
> escape sequence '\.'
> +  if re.match( ".*\.config", opt ):
> +recipe-sysroot-native/usr/bin/symbol_why.py:216: SyntaxWarning: invalid
> escape sequence '\w'
> +  x = re.match( "^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel
> Configuration", line )
> +recipe-sysroot-native/usr/bin/symbol_why.py:495: SyntaxWarning: invalid
> escape sequence '\s'
> +  if re.search( "^#\s*CONFIG_", option ):
> +'''
> +
> +According to [1], use raw strings for regular expression
> +
> +[1] https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes
> +
> +Upstream-Status: Submitted [linux-yocto@lists.yoctoproject.org]
> +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> +---
> + tools/symbol_why.py | 6 +++---
> + 1 file changed, 3 insertions(+), 3 deletions(-)
> +
> +diff --git a/tools/symbol_why.py b/tools/symbol_why.py
> +index 326e84f..4864378 100755
> +--- a/tools/symbol_why.py
> ++++ b/tools/symbol_why.py
> +@@ -158,7 +158,7 @@ for opt in args.args:
> +     elif re.match( "--ksrc=*", opt):
> +         temp, ksrc = opt.split('=', 2)
> +     else:
> +-        if re.match( ".*\.config", opt ):
> ++        if re.match( r".*\.config", opt ):
> +             dotconfig=opt
> +         elif not ksrc:
> +             ksrc=opt
> +@@ -213,7 +213,7 @@ if not os.getenv("KERNELVERSION"):
> +     hconfig = open( dotconfig )
> +     for line in hconfig:
> +         line = line.rstrip()
> +-        x = re.match( "^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel
> Configuration", line )
> ++        x = re.match( r"^#
> .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel Configuration", line )
> +         if x:
> +             os.environ["KERNELVERSION"] = x.group(1)
> +             if verbose:
> +@@ -492,7 +492,7 @@ def split_option( config_option_str ):
> +         opt = m.group(1)
> +         val = m.group(2)
> +     except:
> +-        if re.search( "^#\s*CONFIG_", option ):
> ++        if re.search( r"^#\s*CONFIG_", option ):
> +             # print( "option is a is not set!!! %s" % option )
> +             m = re.match(r"# (CONFIG_[^ ]+) is not set", option )
> +             if m:
> +--
> +2.25.1
> +
> diff --git a/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
> b/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
> index 8eff00821a..7d11889eda 100644
> --- a/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
> +++ b/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
> @@ -16,7 +16,9 @@ PV = "0.3+git"
>
>  inherit native
>
> -SRC_URI = "git://
> git.yoctoproject.org/yocto-kernel-tools.git;branch=master;protocol=https"
> +SRC_URI = "git://
> git.yoctoproject.org/yocto-kernel-tools.git;branch=master;protocol=https \
> +
>  file://0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch \
> +"
>  S = "${WORKDIR}/git"
>
>  do_configure() {
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#208889):
> https://lists.openembedded.org/g/openembedded-core/message/208889
> Mute This Topic: https://lists.openembedded.org/mt/110188794/1050810
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Steve Sakoman Dec. 19, 2024, 1:36 p.m. UTC | #2
On Wed, Dec 18, 2024 at 8:04 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
>
> Please don't take this patch in this format.
>
> Once I've approved and merged the changes into the kern-tools, there will
> be a SRCREV update.
>
> So this is a NACK/

Got it!  Thanks for reviewing.

Steve

> On Wed, Dec 18, 2024 at 5:02 PM Steve Sakoman via lists.openembedded.org <steve=sakoman.com@lists.openembedded.org> wrote:
>>
>> From: Hongxu Jia <hongxu.jia@windriver.com>
>>
>> Python 3.12 emmits a SyntaxWarning when using unescaped
>> character inside a RegEx string.
>> '''
>> recipe-sysroot-native/usr/bin/symbol_why.py:161: SyntaxWarning: invalid escape sequence '\.'
>>   if re.match( ".*\.config", opt ):
>> recipe-sysroot-native/usr/bin/symbol_why.py:216: SyntaxWarning: invalid escape sequence '\w'
>>   x = re.match( "^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel Configuration", line )
>> recipe-sysroot-native/usr/bin/symbol_why.py:495: SyntaxWarning: invalid escape sequence '\s'
>>   if re.search( "^#\s*CONFIG_", option ):
>> '''
>>
>> According to [1], use raw strings for regular expression
>>
>> [1] https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes
>>
>> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
>> Signed-off-by: Steve Sakoman <steve@sakoman.com>
>> ---
>>  ...yntaxWarning-for-RegEx-calls-on-Pyth.patch | 60 +++++++++++++++++++
>>  .../kern-tools/kern-tools-native_git.bb       |  4 +-
>>  2 files changed, 63 insertions(+), 1 deletion(-)
>>  create mode 100644 meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch
>>
>> diff --git a/meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch b/meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch
>> new file mode 100644
>> index 0000000000..e87067c8ac
>> --- /dev/null
>> +++ b/meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch
>> @@ -0,0 +1,60 @@
>> +From 1f64368e4e82e47cd0e0dfe37b0e1b8958566d21 Mon Sep 17 00:00:00 2001
>> +From: Hongxu Jia <hongxu.jia@windriver.com>
>> +Date: Tue, 17 Dec 2024 01:25:29 -0800
>> +Subject: [PATCH] symbol_why: fix SyntaxWarning for RegEx calls on Python 3.12
>> +
>> +Python 3.12 emmits a SyntaxWarning when using unescaped
>> +character inside a RegEx string.
>> +'''
>> +recipe-sysroot-native/usr/bin/symbol_why.py:161: SyntaxWarning: invalid escape sequence '\.'
>> +  if re.match( ".*\.config", opt ):
>> +recipe-sysroot-native/usr/bin/symbol_why.py:216: SyntaxWarning: invalid escape sequence '\w'
>> +  x = re.match( "^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel Configuration", line )
>> +recipe-sysroot-native/usr/bin/symbol_why.py:495: SyntaxWarning: invalid escape sequence '\s'
>> +  if re.search( "^#\s*CONFIG_", option ):
>> +'''
>> +
>> +According to [1], use raw strings for regular expression
>> +
>> +[1] https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes
>> +
>> +Upstream-Status: Submitted [linux-yocto@lists.yoctoproject.org]
>> +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
>> +---
>> + tools/symbol_why.py | 6 +++---
>> + 1 file changed, 3 insertions(+), 3 deletions(-)
>> +
>> +diff --git a/tools/symbol_why.py b/tools/symbol_why.py
>> +index 326e84f..4864378 100755
>> +--- a/tools/symbol_why.py
>> ++++ b/tools/symbol_why.py
>> +@@ -158,7 +158,7 @@ for opt in args.args:
>> +     elif re.match( "--ksrc=*", opt):
>> +         temp, ksrc = opt.split('=', 2)
>> +     else:
>> +-        if re.match( ".*\.config", opt ):
>> ++        if re.match( r".*\.config", opt ):
>> +             dotconfig=opt
>> +         elif not ksrc:
>> +             ksrc=opt
>> +@@ -213,7 +213,7 @@ if not os.getenv("KERNELVERSION"):
>> +     hconfig = open( dotconfig )
>> +     for line in hconfig:
>> +         line = line.rstrip()
>> +-        x = re.match( "^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel Configuration", line )
>> ++        x = re.match( r"^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel Configuration", line )
>> +         if x:
>> +             os.environ["KERNELVERSION"] = x.group(1)
>> +             if verbose:
>> +@@ -492,7 +492,7 @@ def split_option( config_option_str ):
>> +         opt = m.group(1)
>> +         val = m.group(2)
>> +     except:
>> +-        if re.search( "^#\s*CONFIG_", option ):
>> ++        if re.search( r"^#\s*CONFIG_", option ):
>> +             # print( "option is a is not set!!! %s" % option )
>> +             m = re.match(r"# (CONFIG_[^ ]+) is not set", option )
>> +             if m:
>> +--
>> +2.25.1
>> +
>> diff --git a/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb b/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
>> index 8eff00821a..7d11889eda 100644
>> --- a/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
>> +++ b/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
>> @@ -16,7 +16,9 @@ PV = "0.3+git"
>>
>>  inherit native
>>
>> -SRC_URI = "git://git.yoctoproject.org/yocto-kernel-tools.git;branch=master;protocol=https"
>> +SRC_URI = "git://git.yoctoproject.org/yocto-kernel-tools.git;branch=master;protocol=https \
>> +           file://0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch \
>> +"
>>  S = "${WORKDIR}/git"
>>
>>  do_configure() {
>> --
>> 2.34.1
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#208889): https://lists.openembedded.org/g/openembedded-core/message/208889
>> Mute This Topic: https://lists.openembedded.org/mt/110188794/1050810
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [bruce.ashfield@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II
>
diff mbox series

Patch

diff --git a/meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch b/meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch
new file mode 100644
index 0000000000..e87067c8ac
--- /dev/null
+++ b/meta/recipes-kernel/kern-tools/files/0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch
@@ -0,0 +1,60 @@ 
+From 1f64368e4e82e47cd0e0dfe37b0e1b8958566d21 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 17 Dec 2024 01:25:29 -0800
+Subject: [PATCH] symbol_why: fix SyntaxWarning for RegEx calls on Python 3.12
+
+Python 3.12 emmits a SyntaxWarning when using unescaped
+character inside a RegEx string.
+'''
+recipe-sysroot-native/usr/bin/symbol_why.py:161: SyntaxWarning: invalid escape sequence '\.'
+  if re.match( ".*\.config", opt ):
+recipe-sysroot-native/usr/bin/symbol_why.py:216: SyntaxWarning: invalid escape sequence '\w'
+  x = re.match( "^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel Configuration", line )
+recipe-sysroot-native/usr/bin/symbol_why.py:495: SyntaxWarning: invalid escape sequence '\s'
+  if re.search( "^#\s*CONFIG_", option ):
+'''
+
+According to [1], use raw strings for regular expression
+
+[1] https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes
+
+Upstream-Status: Submitted [linux-yocto@lists.yoctoproject.org]
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ tools/symbol_why.py | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/tools/symbol_why.py b/tools/symbol_why.py
+index 326e84f..4864378 100755
+--- a/tools/symbol_why.py
++++ b/tools/symbol_why.py
+@@ -158,7 +158,7 @@ for opt in args.args:
+     elif re.match( "--ksrc=*", opt):
+         temp, ksrc = opt.split('=', 2)
+     else:
+-        if re.match( ".*\.config", opt ):
++        if re.match( r".*\.config", opt ):
+             dotconfig=opt
+         elif not ksrc:
+             ksrc=opt
+@@ -213,7 +213,7 @@ if not os.getenv("KERNELVERSION"):
+     hconfig = open( dotconfig )
+     for line in hconfig:
+         line = line.rstrip()
+-        x = re.match( "^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel Configuration", line )
++        x = re.match( r"^# .*Linux/\w*\s*([0-9]*\.[0-9]*\.[0-9]*).*Kernel Configuration", line )
+         if x:
+             os.environ["KERNELVERSION"] = x.group(1)
+             if verbose:
+@@ -492,7 +492,7 @@ def split_option( config_option_str ):
+         opt = m.group(1)
+         val = m.group(2)
+     except:
+-        if re.search( "^#\s*CONFIG_", option ):
++        if re.search( r"^#\s*CONFIG_", option ):
+             # print( "option is a is not set!!! %s" % option )
+             m = re.match(r"# (CONFIG_[^ ]+) is not set", option )
+             if m:
+-- 
+2.25.1
+
diff --git a/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb b/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
index 8eff00821a..7d11889eda 100644
--- a/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
+++ b/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb
@@ -16,7 +16,9 @@  PV = "0.3+git"
 
 inherit native
 
-SRC_URI = "git://git.yoctoproject.org/yocto-kernel-tools.git;branch=master;protocol=https"
+SRC_URI = "git://git.yoctoproject.org/yocto-kernel-tools.git;branch=master;protocol=https \
+           file://0001-symbol_why-fix-SyntaxWarning-for-RegEx-calls-on-Pyth.patch \
+"
 S = "${WORKDIR}/git"
 
 do_configure() {