Skip to content

Commit

Permalink
Add workaround for latest regex version failing on __version__ access (
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser authored Feb 20, 2019
1 parent d0ddc51 commit ebdcd89
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 - 2017 Isaac Muse
Copyright (c) 2016 - 2019 Isaac Muse

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ http://facelessuser.github.io/backrefs/

Released under the MIT license.

Copyright (c) 2015 - 2018 Isaac Muse <isaacmuse@gmail.com>
Copyright (c) 2015 - 2019 Isaac Muse <isaacmuse@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion backrefs/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,5 @@ def parse_version(ver, pre=False):
return Version(major, minor, micro, release, pre, post, dev)


__version_info__ = Version(4, 0, 1, "final")
__version_info__ = Version(4, 0, 2, "final")
__version__ = __version_info__._get_canonical()
2 changes: 1 addition & 1 deletion backrefs/_bre_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Backrefs Re parser.
Licensed under MIT
Copyright (c) 2011 - 2018 Isaac Muse <isaacmuse@gmail.com>
Copyright (c) 2011 - 2019 Isaac Muse <isaacmuse@gmail.com>
"""
from __future__ import unicode_literals
import re as _re
Expand Down
16 changes: 13 additions & 3 deletions backrefs/_bregex_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
Backrefs Regex parser.
Licensed under MIT
Copyright (c) 2011 - 2018 Isaac Muse <isaacmuse@gmail.com>
Copyright (c) 2011 - 2019 Isaac Muse <isaacmuse@gmail.com>
"""
from __future__ import unicode_literals
import unicodedata as _unicodedata
import copyreg as _copyreg
from . import util as _util
import regex as _regex

_REGEX_COMMENT_FIX = tuple([int(x) for x in _regex.__version__.split('.')]) > (2, 4, 136)
try: # pragma: no cover
from regex import __version__ as _regex_version
except ImportError: # pragma: no cover
from regex.regex import __version__ as _regex_version

try: # pragma: no cover
from regex import _compile_replacement_helper
except ImportError: # pragma: no cover
from regex.regex import _compile_replacement_helper

_REGEX_COMMENT_FIX = tuple([int(x) for x in _regex_version.split('.')]) > (2, 4, 136)

_ASCII_LETTERS = frozenset(
(
Expand Down Expand Up @@ -979,7 +989,7 @@ def regex_parse_template(self, template, pattern):

groups = []
literals = []
replacements = _regex._compile_replacement_helper(pattern, template)
replacements = _compile_replacement_helper(pattern, template)
count = 0
for part in replacements:
if isinstance(part, int):
Expand Down
2 changes: 1 addition & 1 deletion backrefs/bre.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- `\X` - Simplified grapheme clusters (search)
Licensed under MIT
Copyright (c) 2011 - 2018 Isaac Muse <isaacmuse@gmail.com>
Copyright (c) 2011 - 2019 Isaac Muse <isaacmuse@gmail.com>
"""
from __future__ import unicode_literals
import sys as _sys
Expand Down
2 changes: 1 addition & 1 deletion backrefs/bregex.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- `\e` - Escape character (search)
Licensed under MIT
Copyright (c) 2015 - 2018 Isaac Muse <isaacmuse@gmail.com>
Copyright (c) 2015 - 2019 Isaac Muse <isaacmuse@gmail.com>
"""
from __future__ import unicode_literals
import regex as _regex
Expand Down
2 changes: 1 addition & 1 deletion backrefs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Utilities and compatibility abstraction.
Licensed under MIT
Copyright (c) 2015 - 2018 Isaac Muse <isaacmuse@gmail.com>
Copyright (c) 2015 - 2019 Isaac Muse <isaacmuse@gmail.com>
"""
import sys

Expand Down
4 changes: 4 additions & 0 deletions docs/src/markdown/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.0.2

- **FIX**: Fix compatibility issues with latest Regex versions.

## 4.0.1

- **FIX**: Ensure that when generating the Unicode property tables, that the property files are read in with `UTF-8` encoding.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/markdown/license.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MIT license.

Copyright (c) 2015 - 2018 Isaac Muse <isaacmuse@gmail.com>
Copyright (c) 2015 - 2019 Isaac Muse <isaacmuse@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repo_url: https://github.com/facelessuser/backrefs
edit_uri: tree/master/docs/src/markdown
site_description: A library to add additional back references to regular expressions.
copyright: |
Copyright &copy; 2015 - 2018 <a href="https://github.com/facelessuser">Isaac Muse</a>
Copyright &copy; 2015 - 2019 <a href="https://github.com/facelessuser">Isaac Muse</a>
<br><span class="md-footer-custom-text">emoji provided free by </span><a href="http://www.emojione.com">EmojiOne</a>
docs_dir: docs/src/markdown
Expand Down
12 changes: 10 additions & 2 deletions tests/test_bregex.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
from backrefs import _bregex_parse
import regex
import pytest
import _regex_core
import random
import copy
try:
import _regex_core
except ImportError:
from regex import _regex_core


class TestSearchTemplate(unittest.TestCase):
Expand Down Expand Up @@ -101,6 +104,11 @@ def test_posix_property_bad_syntax(self):
def test_cache(self):
"""Test cache."""

try:
from regex import _cache
except ImportError:
from regex.regex import _cache

bregex.purge()
self.assertEqual(bregex._get_cache_size(), 0)
self.assertEqual(bregex._get_cache_size(True), 0)
Expand All @@ -115,7 +123,7 @@ def test_cache(self):
bregex.purge()
self.assertEqual(bregex._get_cache_size(), 0)
self.assertEqual(bregex._get_cache_size(True), 0)
self.assertEqual(len(regex._cache), 0)
self.assertEqual(len(_cache), 0)

def test_infinite_loop_catch(self):
"""Test infinite loop catch."""
Expand Down

0 comments on commit ebdcd89

Please sign in to comment.