diff --git a/django/template/base.py b/django/template/base.py
index c5bddaf..fb6b309 100644
a
|
b
|
class Variable(object):
|
690 | 690 | self.lookups = None |
691 | 691 | self.translate = False |
692 | 692 | self.message_context = None |
693 | | |
| 693 | if not isinstance(var, six.string_types): |
| 694 | raise TypeError( |
| 695 | "Variable must be a string or number, got %s" % type(var)) |
694 | 696 | try: |
695 | 697 | # First try to treat this variable as a number. |
696 | 698 | # |
diff --git a/tests/template_tests/test_parser.py b/tests/template_tests/test_parser.py
index 9422da8..d5d8ec4 100644
a
|
b
|
class ParserTests(TestCase):
|
85 | 85 | self.assertRaises(TemplateSyntaxError, |
86 | 86 | Variable, "article._hidden" |
87 | 87 | ) |
| 88 | # Variables should raise on non string type |
| 89 | self.assertRaises(TypeError, Variable({})) |
88 | 90 | |
89 | 91 | @override_settings(DEBUG=True, TEMPLATE_DEBUG=True) |
90 | 92 | def test_compile_filter_error(self): |