diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 6daf234..da29c7e 100644
a
|
b
|
class WidthRatioNode(Node):
|
498 | 498 | value = float(value) |
499 | 499 | max_value = float(max_value) |
500 | 500 | ratio = (value / max_value) * max_width |
| 501 | result = str(int(round(ratio))) |
501 | 502 | except ZeroDivisionError: |
502 | 503 | return '0' |
503 | | except (ValueError, TypeError): |
| 504 | except (ValueError, TypeError, OverflowError): |
504 | 505 | return '' |
505 | | result = str(int(round(ratio))) |
506 | 506 | |
507 | 507 | if self.asvar: |
508 | 508 | context[self.asvar] = result |
diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py
index 4dcf028..65022b4 100644
a
|
b
|
class TemplateTests(TestCase):
|
1666 | 1666 | |
1667 | 1667 | 'widthratio18': ('{% widthratio a b 100 as %}', {}, template.TemplateSyntaxError), |
1668 | 1668 | 'widthratio19': ('{% widthratio a b 100 not_as variable %}', {}, template.TemplateSyntaxError), |
| 1669 | 'widthratio20': ('{% widthratio a b 100 %}', {'a': float('inf'), 'b': float('inf')}, ''), |
| 1670 | 'widthratio21': ('{% widthratio a b 100 %}', {'a': float('inf'), 'b': 2}, ''), |
1669 | 1671 | |
1670 | 1672 | ### WITH TAG ######################################################## |
1671 | 1673 | 'with01': ('{% with key=dict.key %}{{ key }}{% endwith %}', {'dict': {'key': 50}}, '50'), |