re.search RuntimeError: maximum recursion depth exceeded



  • I have a really simple regular expression that can reliably generate a maximum recursion depth error. Here's the simplest recreate I could figure out:

    >>> import os
    >>> os.uname()
    (sysname='GPy', nodename='GPy', release='1.20.2.rc6', version='v1.11-01f49f7 on 2020-02-28', machine='GPy with ESP32', pybytes='1.3.1')
    >>> import re
    >>> x = """asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfaasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfas\n\nasdf\n"""
    >>> m = re.search('^(.*)\n\n(.*)$', x)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    RuntimeError: maximum recursion depth exceeded
    
    

    This doesn't seem like an unreasonably large string to search. This must be a bug, right?



  • For what it's worth, I tried this on a generic esp32 running generic micropython and it works fine, so it seems likely it's a pycom specific bug:

    >>> import os
    >>> os.uname()
    (sysname='esp32', nodename='esp32', release='1.12.0', version='v1.12 on 2019-12-20', machine='ESP32 module with ESP32')
    >>> import re
    >>> x = """asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfaasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfas\n\nasdf\n"""
    >>> m = re.search('^(.*)\n\n(.*)$', x)
    >>> m
    <match num=3>
    >>> m.group(1), m.group(2)
    ('asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfaasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfas', 'asdf\n')
    
    

Log in to reply
 

Pycom on Twitter