Ticket #3441: VariableDoesNotExist.patch

File VariableDoesNotExist.patch, 1.0 KB (added by (removed), 9 years ago)

VariableDoesNotExist.init refactoring.

  • django/template/__init__.py

    === modified file 'django/template/__init__.py'
     
    117117    pass
    118118
    119119class VariableDoesNotExist(Exception):
    120     pass
    121120
     121    def __init__(self, msg, params=()):
     122        self.msg = msg
     123        self.params = params
     124   
     125    def __str__(self):
     126        return self.mgs % self.params
     127   
    122128class InvalidTemplateLibrary(Exception):
    123129    pass
    124130
     
    658664                    try: # list-index lookup
    659665                        current = current[int(bits[0])]
    660666                    except (IndexError, ValueError, KeyError):
    661                         raise VariableDoesNotExist, "Failed lookup for key [%s] in %r" % (bits[0], current) # missing attribute
     667                        raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bits[0], current)) # missing attribute
    662668                except Exception, e:
    663669                    if not getattr(e, 'silent_variable_failure', False):
    664670                        raise
Back to Top