You're passing
v_inp
as the string to examine for a pattern match via re.search()
. But what you've posted doesn't show where that comes from (the actual function call). If what is passed in is not a string, then regex method will not like it.>>> s1 = "foobar" # a string >>> s2 = 85 # not a string >>> re.search(r"foo", s1) <_sre.SRE_Match object; span=(0, 3), match='foo'> >>> re.search(r"foo", s2) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.6/re.py", line 182, in search return _compile(pattern, flags).search(string) TypeError: expected string or bytes-like objectYou could possibly force it by coercing it to a string, but it's probably better to see what's calling it and if it's passing the right object.
>>> re.search(r"foo", str(s2)) >>>