joxeankoret / diaphora

Diaphora, the most advanced Free and Open Source program diffing tool.
http://diaphora.re
GNU Affero General Public License v3.0
3.58k stars 371 forks source link

Python 3.11: pygments re.compile error #243

Closed kbandla closed 1 year ago

kbandla commented 1 year ago

With Python3.11, pygments fails with the following message:

>>> from pygments import highlight

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kbandla/github/diaphora/pygments/__init__.py", line 37, in <module>
    from pygments.util import StringIO, BytesIO
  File "/home/kbandla/github/diaphora/pygments/util.py", line 27, in <module>
    tag_re = re.compile(r'<(.+?)(\s.*?)?>.*?</.+?>(?uism)')
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kbandla/python/3.11/lib/python3.11/re/__init__.py", line 227, in compile
    return _compile(pattern, flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kbandla/python/3.11/lib/python3.11/re/__init__.py", line 294, in _compile
    p = _compiler.compile(pattern, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kbandla/python/3.11/lib/python3.11/re/_compiler.py", line 743, in compile
    p = _parser.parse(p, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kbandla/python/3.11/lib/python3.11/re/_parser.py", line 980, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kbandla/python/3.11/lib/python3.11/re/_parser.py", line 455, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kbandla/python/3.11/lib/python3.11/re/_parser.py", line 841, in _parse
    raise source.error('global flags not at the start '
re.error: global flags not at the start of the expression at position 24

Python versions 3.7 and later showed a DeprecationWarning:

Flags not at the start of the expression '<(.+?)(\\s.*?)?>.*?</' (truncated)re.compile(r'<(.+?)(\s.*?)?>.*?</.+?>(?uism)')
joxeankoret commented 1 year ago

Yes, this is a known issue. I'll upgrade the pygments version soon.

joxeankoret commented 1 year ago

Should be fixed with 9a852b5c04c318f1844821d4a17026204c395155. Feel free to reopen if you have any issue.