From bdedc84127530fcf71c096ad572bd4306a40b26f Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 20 Jul 2020 14:07:35 +0200 Subject: Fix "invalid escape sequence \w" Python exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (Like > Python exception: : invalid escape sequence \w (lightproof_impl_en.py, line 126), traceback follows > File "instdir/program/pythonloader.py", line 133, in activate > mod = self.getModuleFromUrl( locationUrl ) > File "instdir/program/pythonloader.py", line 101, in getModuleFromUrl > exec(codeobject, mod.__dict__) > File "instdir/share/extensions/dict-en/Lightproof.py", line 6, in > from lightproof_impl_en import locales > File "instdir/program/uno.py", line 345, in _uno_import > return _builtin_import(name, *optargs, **kwargs) I noticed e.g. during UITest_writer_tests3.) Appears those suspicious escapes were present ever since 2214a3731aaffc4a51d1c712dbee553a0ba35af0 "Hungarian sentence checking", 95445a70a29c6a1166a19f483566f2c9cfc7563b "English sentence checking", and c9cdf3fb4752e8b0c641a3aff15d554135beb0e7 "Add Russian grammar checking + update English and Hungarian". Change-Id: Ia2af7e0adb00b4737b22d460dd75fa47a4ae70d5 Reviewed-on: https://gerrit.libreoffice.org/c/dictionaries/+/99047 Tested-by: László Németh Reviewed-by: László Németh --- en/pythonpath/lightproof_impl_en.py | 4 ++-- hu_HU/pythonpath/lightproof_impl_hu_HU.py | 4 ++-- ru_RU/pythonpath/lightproof_impl_ru_RU.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/en/pythonpath/lightproof_impl_en.py b/en/pythonpath/lightproof_impl_en.py index ac668dc..06d44a6 100644 --- a/en/pythonpath/lightproof_impl_en.py +++ b/en/pythonpath/lightproof_impl_en.py @@ -123,14 +123,14 @@ def suggest(rLoc, word): # get the nth word of the input string or None def word(s, n): - a = re.match("(?u)( [-.\w%%]+){" + str(n-1) + "}( [-.\w%%]+)", s) + a = re.match("(?u)( [-.\\w%%]+){" + str(n-1) + "}( [-.\\w%%]+)", s) if not a: return '' return a.group(2)[1:] # get the (-)nth word of the input string or None def wordmin(s, n): - a = re.search("(?u)([-.\w%%]+ )([-.\w%%]+ ){" + str(n-1) + "}$", s) + a = re.search("(?u)([-.\\w%%]+ )([-.\\w%%]+ ){" + str(n-1) + "}$", s) if not a: return '' return a.group(1)[:-1] diff --git a/hu_HU/pythonpath/lightproof_impl_hu_HU.py b/hu_HU/pythonpath/lightproof_impl_hu_HU.py index e933129..ef8fb0a 100644 --- a/hu_HU/pythonpath/lightproof_impl_hu_HU.py +++ b/hu_HU/pythonpath/lightproof_impl_hu_HU.py @@ -126,14 +126,14 @@ def suggest(rLoc, word): # get the nth word of the input string or None def word(s, n): - a = re.match("(?u)( [-.\w%%]+){" + str(n-1) + "}( [-.\w%%]+)", s) + a = re.match("(?u)( [-.\\w%%]+){" + str(n-1) + "}( [-.\\w%%]+)", s) if not a: return '' return a.group(2)[1:] # get the (-)nth word of the input string or None def wordmin(s, n): - a = re.search("(?u)([-.\w%%]+ )([-.\w%%]+ ){" + str(n-1) + "}$", s) + a = re.search("(?u)([-.\\w%%]+ )([-.\\w%%]+ ){" + str(n-1) + "}$", s) if not a: return '' return a.group(1)[:-1] diff --git a/ru_RU/pythonpath/lightproof_impl_ru_RU.py b/ru_RU/pythonpath/lightproof_impl_ru_RU.py index 22eb59e..ffbf054 100644 --- a/ru_RU/pythonpath/lightproof_impl_ru_RU.py +++ b/ru_RU/pythonpath/lightproof_impl_ru_RU.py @@ -125,14 +125,14 @@ def suggest(rLoc, word): # get the nth word of the input string or None def word(s, n): - a = re.match("(?u)( [-.\w%%]+){" + str(n-1) + "}( [-.\w%%]+)", s) + a = re.match("(?u)( [-.\\w%%]+){" + str(n-1) + "}( [-.\\w%%]+)", s) if not a: return '' return a.group(2)[1:] # get the (-)nth word of the input string or None def wordmin(s, n): - a = re.search("(?u)([-.\w%%]+ )([-.\w%%]+ ){" + str(n-1) + "}$", s) + a = re.search("(?u)([-.\\w%%]+ )([-.\\w%%]+ ){" + str(n-1) + "}$", s) if not a: return '' return a.group(1)[:-1] -- cgit