Commit 5ad391e5 authored by Benjamin Bouvier's avatar Benjamin Bouvier Committed by Vincent A

weboob.browser.filters: Regexp uses default if the text value isn't a string

Fixes #438Signed-off-by: Benjamin Bouvier's avatarBenjamin Bouvier <public@benj.me>
parent 478a7cd0
......@@ -595,8 +595,14 @@ class Regexp(Filter):
if isinstance(txt, (tuple, list)):
txt = u' '.join([t.strip() for t in txt.itertext()])
m = self._regex.search(txt) if self.nth == 0 else \
nth(self._regex.finditer(txt), self.nth)
m = None
try:
m = self._regex.search(txt) if self.nth == 0 else \
nth(self._regex.finditer(txt), self.nth)
except TypeError:
msg = '%r is not a string or bytes-like object' % txt
return self.default_or_raise(RegexpError(msg))
if not m:
msg = 'Unable to find %s %s in %r' % (ordinal(self.nth), self.pattern, txt)
return self.default_or_raise(RegexpError(msg))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment