Index: django/template/__init__.py
===================================================================
--- django/template/__init__.py	(revision 12820)
+++ django/template/__init__.py	(working copy)
@@ -745,11 +745,11 @@
                             TypeError,  # unsubscriptable object
                             ):
                         raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute
-                except Exception, e:
-                    if getattr(e, 'silent_variable_failure', False):
-                        current = settings.TEMPLATE_STRING_IF_INVALID
-                    else:
-                        raise
+            except Exception, e:
+                if getattr(e, 'silent_variable_failure', False):
+                    current = settings.TEMPLATE_STRING_IF_INVALID
+                else:
+                    raise
 
         return current
 
Index: tests/regressiontests/templates/tests.py
===================================================================
--- tests/regressiontests/templates/tests.py	(revision 12820)
+++ tests/regressiontests/templates/tests.py	(working copy)
@@ -97,6 +97,10 @@
     def method(self):
         return "OtherClass.method"
 
+class SilentGetItemClass(object):
+    def __getitem__(self, key):
+        raise SomeException
+
 class UTF8Class:
     "Class whose __str__ returns non-ASCII data"
     def __str__(self):
@@ -465,6 +469,11 @@
             'basic-syntax26': (r'{{ "\"fred\"" }}', {}, "\"fred\""),
             'basic-syntax27': (r'{{ _("\"fred\"") }}', {}, "\"fred\""),
 
+            # regression test for ticket #12554
+            # make sure a silent_variable_failure Exception is supressed
+            # on dictionary lookup
+            'basic-syntax28': ("{{ a.b }}", {'a': SilentGetItemClass()}, ('', 'INVALID')),
+
             # List-index syntax allows a template to access a certain item of a subscriptable object.
             'list-index01': ("{{ var.1 }}", {"var": ["first item", "second item"]}, "second item"),
 
