From 8dce37f6b88f0d7f17629c3bef73f14b68263901 Mon Sep 17 00:00:00 2001 From: Mike Naberezny Date: Fri, 12 Apr 2024 12:21:46 -0700 Subject: [PATCH] Fix regular expression warnings on Python 3.12 --- CHANGES.rst | 2 ++ py65/monitor.py | 4 ++-- py65/utils/addressing.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index e0a74fd..29d0a84 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ dropped when pasting in larger amounts of text. This makes it possible to paste programs into EhBASIC and Taliforth. Patch by SamCoVT. +- Fixed regular expression warnings on Python 3.12. + - The ``fill`` command in the monitor now shows an error message if an address or value is out of range. diff --git a/py65/monitor.py b/py65/monitor.py index 99e8fcf..42f755f 100644 --- a/py65/monitor.py +++ b/py65/monitor.py @@ -239,7 +239,7 @@ class Monitor(cmd.Cmd): line = command break - pattern = '^%s\s+' % re.escape(shortcut) + pattern = r'^%s\s+' % re.escape(shortcut) matches = re.match(pattern, line) if matches: start, end = matches.span() @@ -580,7 +580,7 @@ class Monitor(cmd.Cmd): if args == '': return - pairs = re.findall('([^=,\s]*)=([^=,\s]*)', args) + pairs = re.findall(r'([^=,\s]*)=([^=,\s]*)', args) if pairs == []: return self._output("Syntax error: %s" % args) diff --git a/py65/utils/addressing.py b/py65/utils/addressing.py index 29c4054..ad8e995 100644 --- a/py65/utils/addressing.py +++ b/py65/utils/addressing.py @@ -61,7 +61,7 @@ class AddressParser(object): return self.labels[num] else: - matches = re.match('^([^\s+-]+)\s*([+\-])\s*([$+%]?\d+)$', num) + matches = re.match(r'^([^\s+-]+)\s*([+\-])\s*([$+%]?\d+)$', num) if matches: label, sign, offset = matches.groups() @@ -88,7 +88,7 @@ class AddressParser(object): """Parse a string containing an address or a range of addresses into a tuple of (start address, end address) """ - matches = re.match('^([^:,]+)\s*[:,]+\s*([^:,]+)$', addresses) + matches = re.match(r'^([^:,]+)\s*[:,]+\s*([^:,]+)$', addresses) if matches: start, end = map(self.number, matches.groups(0)) else: