From: Soeren Apel Date: Tue, 1 Oct 2024 15:24:42 +0000 (+0200) Subject: Fix escape sequences treated as unicode laterals X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=03dc5f85050301d31aa0803e85bdda1374109b49;p=libsigrokdecode.git Fix escape sequences treated as unicode laterals Since Python 3.6, unrecognized escape sequences produce a DeprecationWarning. Since Python 3.12, unrecognized escape sequences produce a SyntaxWarning. In a future Python version they will be eventually a SyntaxError. https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals Fix these by using raw string literals. --- diff --git a/decoders/arm_etmv3/pd.py b/decoders/arm_etmv3/pd.py index a0bbd94..95a7eb7 100644 --- a/decoders/arm_etmv3/pd.py +++ b/decoders/arm_etmv3/pd.py @@ -212,10 +212,10 @@ class Decoder(srd.Decoder): disasm = disasm.decode('utf-8', 'replace') - instpat = re.compile('\s*([0-9a-fA-F]+):\t+([0-9a-fA-F ]+)\t+([a-zA-Z][^;]+)\s*;?.*') - branchpat = re.compile('(b|bl|b..|bl..|cbnz|cbz)(?:\.[wn])?\s+(?:r[0-9]+,\s*)?([0-9a-fA-F]+)') - filepat = re.compile('[^\s]+[/\\\\]([a-zA-Z0-9._-]+:[0-9]+)(?:\s.*)?') - funcpat = re.compile('[0-9a-fA-F]+\s*<([^>]+)>:.*') + instpat = re.compile(r'\s*([0-9a-fA-F]+):\t+([0-9a-fA-F ]+)\t+([a-zA-Z][^;]+)\s*;?.*') + branchpat = re.compile(r'(b|bl|b..|bl..|cbnz|cbz)(?:\.[wn])?\s+(?:r[0-9]+,\s*)?([0-9a-fA-F]+)') + filepat = re.compile(r'[^\s]+[/\\\\]([a-zA-Z0-9._-]+:[0-9]+)(?:\s.*)?') + funcpat = re.compile(r'[0-9a-fA-F]+\s*<([^>]+)>:.*') prev_src = '' prev_file = '' diff --git a/decoders/arm_itm/pd.py b/decoders/arm_itm/pd.py index 8ceeac4..136ef76 100644 --- a/decoders/arm_itm/pd.py +++ b/decoders/arm_itm/pd.py @@ -113,9 +113,9 @@ class Decoder(srd.Decoder): disasm = disasm.decode('utf-8', 'replace') - instpat = re.compile('\s*([0-9a-fA-F]+):\t+([0-9a-fA-F ]+)\t+([a-zA-Z][^;]+)\s*;?.*') - filepat = re.compile('[^\s]+[/\\\\]([a-zA-Z0-9._-]+:[0-9]+)(?:\s.*)?') - funcpat = re.compile('[0-9a-fA-F]+\s*<([^>]+)>:.*') + instpat = re.compile(r'\s*([0-9a-fA-F]+):\t+([0-9a-fA-F ]+)\t+([a-zA-Z][^;]+)\s*;?.*') + filepat = re.compile(r'[^\s]+[/\\\\]([a-zA-Z0-9._-]+:[0-9]+)(?:\s.*)?') + funcpat = re.compile(r'[0-9a-fA-F]+\s*<([^>]+)>:.*') prev_file = '' prev_func = '' diff --git a/decoders/ds1307/pd.py b/decoders/ds1307/pd.py index 51d673d..f93ae63 100644 --- a/decoders/ds1307/pd.py +++ b/decoders/ds1307/pd.py @@ -48,11 +48,11 @@ DS1307_I2C_ADDRESS = 0x68 def regs_and_bits(): l = [('reg_' + r.lower(), r + ' register') for r in regs] - l += [('bit_' + re.sub('\/| ', '_', b).lower(), b + ' bit') for b in bits] + l += [('bit_' + re.sub(r'\/| ', '_', b).lower(), b + ' bit') for b in bits] return tuple(l) a = ['REG_' + r.upper() for r in regs] + \ - ['BIT_' + re.sub('\/| ', '_', b).upper() for b in bits] + \ + ['BIT_' + re.sub(r'\/| ', '_', b).upper() for b in bits] + \ ['READ_DATE_TIME', 'WRITE_DATE_TIME', 'READ_REG', 'WRITE_REG', 'WARNING'] Ann = SrdIntEnum.from_list('Ann', a) diff --git a/decoders/spiflash/pd.py b/decoders/spiflash/pd.py index 26f3a24..c9c3edf 100644 --- a/decoders/spiflash/pd.py +++ b/decoders/spiflash/pd.py @@ -24,7 +24,7 @@ from .lists import * L = len(cmds) -a = [re.sub('\/', '_', c[0]).replace('2READ', 'READ2X') for c in cmds.values()] + ['BIT', 'FIELD', 'WARN'] +a = [re.sub(r'\/', '_', c[0]).replace('2READ', 'READ2X') for c in cmds.values()] + ['BIT', 'FIELD', 'WARN'] Ann = SrdIntEnum.from_list('Ann', a) def cmd_annotation_classes():