Skip to content

Commit 3d98428

Browse files
Merge pull request #12 from jmelahman/jamison/invalid-escape-sequence
[chore] fix "SyntaxError: invalid escape sequence"
2 parents c663c61 + 2a04eb9 commit 3d98428

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/whoosh/analysis/filters.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
\\S+? # URL body
5454
(?=\\s|[.]\\s|$|[.]$) # Stop at space/end, or a dot followed by space/end
5555
) | ( # or...
56-
\w+([:.]?\w+)* # word characters, with opt. internal colons/dots
56+
\\w+([:.]?\\w+)* # word characters, with opt. internal colons/dots
5757
)
5858
""", verbose=True)
5959

@@ -145,7 +145,7 @@ def __call__(self, tokens):
145145

146146

147147
class TeeFilter(Filter):
148-
"""Interleaves the results of two or more filters (or filter chains).
148+
r"""Interleaves the results of two or more filters (or filter chains).
149149
150150
NOTE: because it needs to create copies of each token for each sub-filter,
151151
this filter is quite slow.

src/whoosh/analysis/intraword.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535

3636
class CompoundWordFilter(Filter):
37-
"""Given a set of words (or any object with a ``__contains__`` method),
37+
r"""Given a set of words (or any object with a ``__contains__`` method),
3838
break any tokens in the stream that are composites of words in the word set
3939
into their individual parts.
4040
@@ -272,7 +272,7 @@ class IntraWordFilter(Filter):
272272
>>> iwf_i = IntraWordFilter(mergewords=True, mergenums=True)
273273
>>> iwf_q = IntraWordFilter(mergewords=False, mergenums=False)
274274
>>> iwf = MultiFilter(index=iwf_i, query=iwf_q)
275-
>>> analyzer = RegexTokenizer(r"\S+") | iwf | LowercaseFilter()
275+
>>> analyzer = RegexTokenizer(r"\\S+") | iwf | LowercaseFilter()
276276
277277
(See :class:`MultiFilter`.)
278278
"""
@@ -282,7 +282,7 @@ class IntraWordFilter(Filter):
282282
__inittypes__ = dict(delims=text_type, splitwords=bool, splitnums=bool,
283283
mergewords=bool, mergenums=bool)
284284

285-
def __init__(self, delims=u("-_'\"()!@#$%^&*[]{}<>\|;:,./?`~=+"),
285+
def __init__(self, delims=u("-_'\"()!@#$%^&*[]{}<>\\|;:,./?`~=+"),
286286
splitwords=True, splitnums=True,
287287
mergewords=False, mergenums=False):
288288
"""

src/whoosh/lang/paicehusk.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class PaiceHuskStemmer(object):
3030
(?P<cont>[.>])
3131
""", re.UNICODE | re.VERBOSE)
3232

33-
stem_expr = re.compile("^\w+", re.UNICODE)
33+
stem_expr = re.compile(r"^\w+", re.UNICODE)
3434

3535
def __init__(self, ruletable):
3636
"""

src/whoosh/lang/porter2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def remove_initial_apostrophe(word):
6464
def capitalize_consonant_ys(word):
6565
if word.startswith('y'):
6666
word = 'Y' + word[1:]
67-
return ccy_exp.sub('\g<1>Y', word)
67+
return ccy_exp.sub(r'\g<1>Y', word)
6868

6969

7070
def step_0(word):

tests/test_analysis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def test_stop_lang():
520520

521521

522522
def test_issue358():
523-
t = analysis.RegexTokenizer("\w+")
523+
t = analysis.RegexTokenizer(r"\w+")
524524
with pytest.raises(analysis.CompositionError):
525525
_ = t | analysis.StandardAnalyzer()
526526

0 commit comments

Comments
 (0)