[Python] re.search() raises recursion depth error when in thread

Discussão em 'Python' iniciado por Stack, Abril 13, 2025.

  1. Stack

    Stack Membro Participativo

    In MicroPython, re.findall() does not exist. Therefore, I made one myself:

    def findAll(pattern, s, flags = 0):
    found = []
    while True:
    m = re.search(pattern, s, flags)
    if m:
    g = m.groups()
    s = s[m.span()[1]:]
    found.append(g[0] if len (g) == 1 else g)
    else:
    return found


    This works well in all my tests, equally in cPython and uPython. However, in uPython, when called from a separate thread (Pico-W), I get an exception that I do not understand:

    File "src/platforms/utils.py", line 16, in findAll
    RuntimeError: maximum recursion depth exceeded


    (line 16 is the first line in the loop, m = re.search(...))

    The pattern is '\x01\x05\x02(.+)\x03\x04'; the searched string one or more repetitions of the pattern with a JSON-like string in the middle.

    What might be causing this and how to solve it?

    Continue reading...

Compartilhe esta Página