-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
safe_range has previously used xrange to get the length of a sequence.
rng = xrange(*args)
if len(rng) > MAX_RANGE:
raise OverflowError('range too big, maximum size for range is %d' %
MAX_RANGE)
However since porting to Python 3 it uses range which behaves differently in Python 2 and 3. On Python 2 it will try to generate the whole sequence in memory before measuring the length -- which can cause an out of memory error.
Expected Behavior
safe_range(100000000000) should raise an OverflowError
Actual Behavior
safe_range(100000000000) attempts to generate a huge list in memory
Template Code
{%for n in range(100000000000) %}{{n}}{% endfor %}Your Environment
- Python version: 2.7
- Jinja version: 2.10
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels