why this code giving recursion error????

dn PythonList at DancesWithMice.info
Sun Jun 26 06:55:16 EDT 2022


On 26/06/2022 22.48, נתי שטרן wrote:
> def compile(p, flags=0):
>         # internal: convert pattern list to internal format
> 
>         if (isinstance(p,str)):
>             pattern = p
>             p = sre_parse.parse(p, flags)
>         else:
>             pattern = None
> 
>         code = _code(p, flags)
> 
>         if flags & SRE_FLAG_DEBUG:
>             print()
>             dis(code)
> 
>         # map in either direction
>         groupindex = p.state.groupdict
>         indexgroup = [None] * p.state.groups
>         for k, i in groupindex.items():
>             indexgroup[i] = k
> 
>         return sre_compile.compile(
>             pattern, flags | p.state.flags, code,
>             p.state.groups-1,
>             groupindex, tuple(indexgroup)
>         )


Why would any code give a recursion error?

With recursion problems, the first question to ask is: how does this
thing stop?

Have you built some test-data with only a handful of items, and thus a
predictable result. Does that result occur? If not, where are the
differences occurring?
-- 
Regards,
=dn


More information about the Python-list mailing list