Resolves an invalid escape sequence in a regex string that occurs because the string was not marked as a raw string, so backslash characters create unexpected escape sequences.
This was brought to light due to Python 3.12 now detecting invalid escape sequences and generates a warning. It is best practice to always use raw strings for regex strings. Cc: Rebecca Cran <rebe...@bsdio.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Bob Feng <bob.c.f...@intel.com> Cc: Yuwei Chen <yuwei.c...@intel.com> Signed-off-by: Joey Vagedes <joeyvage...@gmail.com> --- BaseTools/Scripts/BinToPcd.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index 460c08b7f7cd..43fc458b0426 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -10,13 +10,12 @@ BinToPcd ''' from __future__ import print_function -import sys import argparse -import re -import xdrlib import io -import struct import math +import re +import struct +import sys # # Globals for help information @@ -38,13 +37,13 @@ if __name__ == '__main__': return Value def ValidatePcdName (Argument): - if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']: + if re.split (r'[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']: Message = '{Argument} is not in the form <PcdTokenSpaceGuidCName>.<PcdCName>'.format (Argument = Argument) raise argparse.ArgumentTypeError (Message) return Argument def ValidateGuidName (Argument): - if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']: + if re.split (r'[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']: Message = '{Argument} is not a valid GUID C name'.format (Argument = Argument) raise argparse.ArgumentTypeError (Message) return Argument -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110448): https://edk2.groups.io/g/devel/message/110448 Mute This Topic: https://groups.io/mt/102305837/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-