# HG changeset patch # User cmlenz # Date 1157014177 0 # Node ID bafa1cc49c2f74529b79d66dbb250ea2f8814c76 # Parent e8c43127d9a994f66681395e06dc4c0eb390e951 Store original message in exceptions as `msg` ivar. diff --git a/markup/input.py b/markup/input.py --- a/markup/input.py +++ b/markup/input.py @@ -34,6 +34,7 @@ def __init__(self, message, filename='', lineno=-1, offset=-1): Exception.__init__(self, message) + self.msg = message self.filename = filename self.lineno = lineno self.offset = offset diff --git a/markup/output.py b/markup/output.py --- a/markup/output.py +++ b/markup/output.py @@ -347,7 +347,7 @@ if kind is EMPTY: if tagname not in empty_elems: - buf.append('' % tagname) + buf += ['' % tagname] yield Markup(''.join(buf)) diff --git a/markup/template.py b/markup/template.py --- a/markup/template.py +++ b/markup/template.py @@ -45,7 +45,8 @@ def __init__(self, message, filename='', lineno=-1, offset=-1): if isinstance(message, SyntaxError) and message.lineno is not None: message = str(message).replace(' (line %d)' % message.lineno, '') - message = '%s (%s, line %d)' % (message, filename, lineno) + self.msg = message + message = '%s (%s, line %d)' % (self.msg, filename, lineno) TemplateError.__init__(self, message) self.filename = filename self.lineno = lineno @@ -61,8 +62,8 @@ """ def __init__(self, name, filename='', lineno=-1): - msg = 'bad directive "%s"' % name.localname - TemplateSyntaxError.__init__(self, msg, filename, lineno) + message = 'bad directive "%s"' % name.localname + TemplateSyntaxError.__init__(self, message, filename, lineno) class TemplateNotFound(TemplateError):