andreasvc / pyre2

Python wrapper for RE2
BSD 3-Clause "New" or "Revised" License
99 stars 33 forks source link

Brocken compatibility with Python < 3.11 #42

Closed evgeniyDorogoy closed 1 year ago

evgeniyDorogoy commented 1 year ago

It appears that a recent change to the library has caused some compatibility issues with older versions of Python.

Specifically, the commit at https://github.com/andreasvc/pyre2/commit/01c73c9dac4f06c0e1e41519fa8f874bf02fb1b0 has broken backward compatibility for Python versions lower than 3.11.

When attempting to import the library with the line import re2, an error is encountered that results in the traceback shown below:

  File "/Users/evgeniydorogoy/.pyenv/versions/3.8.5/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/evgeniydorogoy/Projects/api/admin.py", line 6, in <module>
    from lexicockpit.api.forms import PatternForm, TicketForm
  File "/Users/evgeniydorogoy/Projects/api/forms.py", line 18, in <module>
    from lexicockpit.backend import validation
  File "/Users/evgeniydorogoy/Projects/backend/validation.py", line 5, in <module>
    import re2
  File "re2.pyx", line 132, in init re2
AttributeError: module 'enum' has no attribute 'global_enum'

Fortunately, for those who want to use the library with older Python versions, this issue can be resolved by reverting to the previous commit at https://github.com/andreasvc/pyre2/commit/8d853ab5076e959eb980ebd2ddbd338f491b58cd.

andreasvc commented 1 year ago

Thanks for the heads up. That commit needs a check for a minimal Python version. You're welcome to make a pull request ;)