diff --git a/site_scons/site_tools/micropython/qstrdefs.py b/site_scons/site_tools/micropython/qstrdefs.py index 9563067d42..5e4e1f2bb2 100644 --- a/site_scons/site_tools/micropython/qstrdefs.py +++ b/site_scons/site_tools/micropython/qstrdefs.py @@ -5,8 +5,9 @@ QSTR_BLACKLIST = set(['NULL', 'number_of']) def process(source, target): + re_qstr = re.compile(r'MP_QSTR_[_a-zA-Z0-9]+') for line in source: - for match in re.findall(r'MP_QSTR_[_a-zA-Z0-9]+', line): + for match in re_qstr.findall(line): name = match.replace('MP_QSTR_', '') if name not in QSTR_BLACKLIST: target.write('Q(%s)\n' % name)