andreikop / enki

A text editor for programmers
http://enki-editor.org
GNU General Public License v2.0
161 stars 39 forks source link

Exception on Ubuntu 14.04 regex #351

Closed andreikop closed 8 years ago

andreikop commented 8 years ago

On Ubuntu 14.04 python-regex version 0.1.20140216-1 is available. With this version I have the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/enki/lib/future.py", line 480, in onDoneSignal
    future._g(future)
  File "/usr/local/lib/python2.7/dist-packages/enki/plugins/preview/preview_sync.py", line 648, in _movePreviewPaneToIndex
    webIndex = future.result
  File "/usr/local/lib/python2.7/dist-packages/enki/lib/future.py", line 405, in _invoke
    self._result = self._f(*self._args, **self._kwargs)
  File "/usr/local/lib/python2.7/dist-packages/enki/plugins/preview/approx_match.py", line 211, in findApproxTextInTarget
    mo = findApproxText(searchText[begin:end], targetText)
  File "/usr/local/lib/python2.7/dist-packages/enki/plugins/preview/approx_match.py", line 149, in findApproxText
    moError = sum(mo.fuzzy_counts)
AttributeError: '_regex.Match' object has no attribute 'fuzzy_counts'

Bryan, could you check if we can leave with this version or should install regex from pip but not from .deb. Even if we can't work on old regex, we should recognize it and avoid exceptions.

bjones1 commented 8 years ago

Aargh. Old packages are so painful. We definitely need a recent version; prior to 7-Nov-2015, regex had some serious fuzzy matching bugs. To fix this, I'd like to use pkg_resources. Any objections?

import pkg_resources

# The `regex <https://pypi.python.org/pypi/regex>`_ module supports approximate
# matching. Make sure it is recent enough to be usable.
import regex
try:
  # Get the version of regex. See https://pythonhosted.org/setuptools/pkg_resources.html#distribution-attributes.
  regexVersion = pkg_resources.get_distribution('regex').parsed_version
  # Issues I filed before this make regex unusable. See #166, #167, andd #169 at
  # https://bitbucket.org/mrabarnett/mrab-regex/issues. For version parse, see
  # https://pythonhosted.org/setuptools/pkg_resources.html#parsing-utilities.
  assert regexVersion >= pkg_resources.parse_version('2015.11.07')
except AssertionError, ValueError:
  raise ImportError
andreikop commented 8 years ago

The fix is merged!