Possible bug in 're' module Python 3.12.6 Linux Mint 22 'global flags not at the start of the expression at position 78'

Hi

I am trying to build EasyABC v1.3.8.7 (EasyABC download | SourceForge.net)

I get the following error when running the main python file easy_abc.py:

Exception has occurred: error
global flags not at the start of the expression at position 78
File “/home/ian/EasyABC/abc_search.py”, line 8, in
remove_non_notes = re.compile(r’(?xm)’ + ‘|’.join([
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ian/EasyABC/easy_abc.py”, line 120, in
from abc_search import abc_matches_iter
re.error: global flags not at the start of the expression at position 78

multi-line instruction is as follows:

remove_non_notes = re.compile(r’(?xm)’ + ‘|’.join([
r’%%beginps(.|\s)+?%%endps’, # remove embedded postscript
r’%%begintext(.|\s)+?%%endtext’, # remove text
r’[\w:.?]‘, # remove embedded fields
r’(?m)^\w:.
?', # remove normal fields r'(?m)%.*‘, # remove comments
r’[\w:.?]‘, # remove embedded fields
r’\“‘, # remove escaped " characters
r’”.
?“‘, # remove strings
r’\”‘, # remove escaped quote characters
r’{.?}‘, # remove grace notes
r’!.+?!‘, # remove ornaments like eg. !pralltriller!
r’+.+?+‘, # remove ornaments like eg. +pralltriller+
r’{.
?}', # remove grace notes
]))

Is this a bug?

I notice that the following import from module re cannot be found:
/usr/lib/python3.12/re/init.py line 127

import _sre

image

It expects an ancient version of Python. This isn’t a bug in re, it’s just that the thing you’re installing won’t work on a modern Python. You’ll have to make some changes.

2 Likes