Skip to contentSkip to conversation

pylibfdt: Fix "invalid escape sequence '\w'" in setup.py

PATCH In review Tom Rini 2 participants 3 messages Feb 20, 2024 – Mar 1, 2024 Device tree

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 pylibfdt: Fix "invalid escape sequence '\w'" in setup.py

From: Florian Schmaus <[email protected]>

Once u-boot's build system invokes

python3 scripts/dtc/pylibfdt/setup.py --quiet build_ext --inplace

it may fail with

scripts/dtc/pylibfdt/setup.py:40: SyntaxWarning: invalid escape sequence '\w'
RE_KEY_VALUE = re.compile('(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')

depending on the used Python version.

Explicitly mark the regex string as raw string to avoid the warning.

---
 scripts/dtc/pylibfdt/setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/dtc/pylibfdt/setup.py +1 -1
index 8baae08770ca..c6fe5a6a446f 100755
@@ -37,7 +37,7 @@
     long_description = fh.read()
 
 # Decodes a Makefile assignment line into key and value (and plus for +=)
-RE_KEY_VALUE = re.compile('(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')
+RE_KEY_VALUE = re.compile(r'(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')
 
 def get_top_builddir():
     if '--top-builddir' in sys.argv:
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Tom Rini

From: Florian Schmaus <[email protected]>

Once u-boot's build system invokes

python3 scripts/dtc/pylibfdt/setup.py --quiet build_ext --inplace

it may fail with

Quoted 8 lines

scripts/dtc/pylibfdt/setup.py:40: SyntaxWarning: invalid escape sequence '\w'
RE_KEY_VALUE = re.compile('(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')

depending on the used Python version.

Explicitly mark the regex string as raw string to avoid the warning.

Quoted 17 lines
---
  scripts/dtc/pylibfdt/setup.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/dtc/pylibfdt/setup.py +1 -1
index 8baae08770ca..c6fe5a6a446f 100755
@@ -37,7 +37,7 @@
      long_description = fh.read()
 
  # Decodes a Makefile assignment line into key and value (and plus for +=)
-RE_KEY_VALUE = re.compile('(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')
+RE_KEY_VALUE = re.compile(r'(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')
 
  def get_top_builddir():
      if '--top-builddir' in sys.argv:
author
#2 lore raw
In reply to Tom Rini
Quoted 11 lines · Tom Rini

From: Florian Schmaus <[email protected]>

Once u-boot's build system invokes

python3 scripts/dtc/pylibfdt/setup.py --quiet build_ext --inplace

it may fail with

scripts/dtc/pylibfdt/setup.py:40: SyntaxWarning: invalid escape sequence '\w'
RE_KEY_VALUE = re.compile('(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')

Quoted 6 lines

depending on the used Python version.

Explicitly mark the regex string as raw string to avoid the warning.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom