Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Strings with many environment variables cause a RecursionError #61

Open
jorisguex opened this issue Oct 27, 2023 · 1 comment
Open

Comments

@jorisguex
Copy link

jorisguex commented Oct 27, 2023

When expanding long strings with many environment variables, a RecursionError occurs.
See a minimal reproducible error here:

# This causes 'RecursionError: maximum recursion depth exceeded'
import expandvars
long_string = " ".join("$VAR" for _ in range(1000))
expandvars.expand(long_string)

Manually increasing the Python recursion limit can increase how many environment variables can be expanded:

# No exception
import expandvars
import sys
sys.setrecursionlimit(2000)
long_string = " ".join("$VAR" for _ in range(1000))
expandvars.expand(long_string)

It seems like internal expand() and expand_vars() functions call each other recursively, causing the issue.

@sayanarijit
Copy link
Owner

Thanks for reporting. A rewrite (using iterative approach) has been pending for some time. I'll start working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants