Skip to content

Commit

Permalink
modify Error given on range limit
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Oct 2, 2018
1 parent 1d3d7b6 commit 46f1d83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/RestrictedPython/Limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def limited_range(iFirst, *args):
if iLen < 0:
iLen = 0
if iLen >= RANGELIMIT:
raise ValueError('range() too large')
raise OverflowError('To be created range() object would be to large, in RestrictedPython we only allow ' + str(RANGELIMIT) + ' elements in a range.') # NOQA: E501
return range(iStart, iEnd, iStep)


Expand Down
3 changes: 2 additions & 1 deletion tests/builtins/test_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def test_limited_range_zero_step():


def test_limited_range_range_overflow():
with pytest.raises(ValueError):
with pytest.raises(OverflowError) as excinfo:
limited_range(0, 5000, 1)
assert 'To be created range() object would be to large, in RestrictedPython we only allow 1000 elements in a range.' in str(excinfo.value) # NOQA: E501


def test_limited_list_valid_list_input():
Expand Down

0 comments on commit 46f1d83

Please sign in to comment.