Skip to content

Commit

Permalink
python3Packages.dateparser: fix regex compatibility
Browse files Browse the repository at this point in the history
Patch by thmo (THomas Moschny) taken from
scrapinghub/dateparser#1045 (comment).

Also relaxes the regex version constraint.
  • Loading branch information
mweinelt authored and SuperSandro2000 committed Sep 17, 2022
1 parent 08c2172 commit b19d1ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkgs/development/python-modules/dateparser/default.nix
Expand Up @@ -29,7 +29,15 @@ buildPythonPackage rec {
sha256 = "sha256-bDup3q93Zq+pvwsy/lQy2byOMjG6C/+7813hWQMbZRU=";
};

patches = [
./regex-compat.patch
];

postPatch = ''
substituteInPlace setup.py --replace \
'regex !=2019.02.19,!=2021.8.27,<2022.3.15' \
'regex'
# https://github.com/scrapinghub/dateparser/issues/1053
substituteInPlace tests/test_search.py --replace \
"('June 2020', datetime.datetime(2020, 6, datetime.datetime.utcnow().day, 0, 0))," \
Expand Down
11 changes: 11 additions & 0 deletions pkgs/development/python-modules/dateparser/regex-compat.patch
@@ -0,0 +1,11 @@
--- a/dateparser/languages/locale.py
+++ b/dateparser/languages/locale.py
@@ -169,7 +169,7 @@ class Locale:
if normalize:
value = list(map(normalize_unicode, value))
pattern = '|'.join(sorted(value, key=len, reverse=True))
- pattern = DIGIT_GROUP_PATTERN.sub(r'?P<n>\d+', pattern)
+ pattern = pattern.replace(r'\d+', r'?P<n>\d+')
pattern = re.compile(r'^(?:{})$'.format(pattern), re.UNICODE | re.IGNORECASE)
relative_dictionary[pattern] = key
return relative_dictionary

0 comments on commit b19d1ba

Please sign in to comment.