Issue 30896: BytesWarning in re module when compiling certain bytes patterns (original) (raw)

This code in sre_parse (line 738 and down):

                        warnings.warn(
                            'Flags not at the start of the expression %s%s' % (
                                source.string[:20],  # truncate long regexes
                                ' (truncated)' if len(source.string) > 20 else '',
                            ),
                            DeprecationWarning, stacklevel=7
                        )

triggers a BytesWarning if you do _line_re = re.compile(br'^(.*?)$(?m)').

The fix should be simple; I can try to get a PR in over the next few days.