From 9eb75b6b379138c85e894e7d5bdba1b415ce4f1a Mon Sep 17 00:00:00 2001 From: Malte Lau Petersen Date: Tue, 2 Dec 2025 10:31:11 +0100 Subject: [PATCH] Fix invalid regex escapes \d is interpreted as the byte "\d" rather than the characters "\" and "d" which the python regex engine is looking for. Double backslash escapes the "\" to produce the correct behaviour. In python 3.6 and onwards, this bug produces SyntaxWarning: invalid escape sequence '\d' --- stormdb/access.py | 2 +- stormdb/cluster.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stormdb/access.py b/stormdb/access.py index cccadf0..3651a43 100644 --- a/stormdb/access.py +++ b/stormdb/access.py @@ -653,7 +653,7 @@ def filter_series(self, key_val_pair[1].sort(key=lambda x: os.path.splitext(x)[0]) elif 'path' in key_val_pair[0]: - m = re.search('\d{3}\.(.+?)/files', key_val_pair[1]) + m = re.search('\\d{3}\.(.+?)/files', key_val_pair[1]) info.append(['seriename', m.group(1)]) info.append(key_val_pair) info_dict = {key: value for (key, value) in info} diff --git a/stormdb/cluster.py b/stormdb/cluster.py index f4bdc7c..8660084 100644 --- a/stormdb/cluster.py +++ b/stormdb/cluster.py @@ -106,7 +106,7 @@ def get_memlimit_per_process(self, queue): lim = self._query('qconf -sq ' + queue + '| grep h_vmem | awk {\'print $2\'}')[0] - _, lim_int, lim_units = re.split('(\d+)', lim) + _, lim_int, lim_units = re.split('(\\d+)', lim) assert isinstance(int(lim_int), int) assert isinstance(lim_units, string_types) @@ -238,8 +238,8 @@ def __init__(self, 'Maximum number of parallel threads is one (1) when total ' 'memory consumption is specified.') # XXX would be nice with some sanity checking here... - _, totmem, totmem_unit = re.split('(\d+)', self.total_memory) - _, memlim, memlim_unit = re.split('(\d+)', h_vmem) + _, totmem, totmem_unit = re.split('(\\d+)', self.total_memory) + _, memlim, memlim_unit = re.split('(\\d+)', h_vmem) if totmem_unit != memlim_unit: units = dict(k=1e3, m=1e6, g=1e9, t=1e12) @@ -365,7 +365,7 @@ def submit(self, fake=False, sh_file='~/submit_job.sh'): else: # py2-3 safety output = output.decode('ascii', 'ignore').rstrip() - m = re.search('(\d+)', output) + m = re.search('(\\d+)', output) self._jobid = m.group(1) if self._cleanup_qsub_job: self._delete_qsub_job()