end of line sequence is no configurable
--HG--
branch : trunk
diff --git a/jinja2/exceptions.py b/jinja2/exceptions.py
index 147ddb9..154cf44 100644
--- a/jinja2/exceptions.py
+++ b/jinja2/exceptions.py
@@ -14,16 +14,6 @@
"""Baseclass for all template errors."""
-class UndefinedError(TemplateError):
- """Raised if a template tries to operate on :class:`Undefined`."""
-
-
-class SecurityError(TemplateError):
- """Raised if a template tries to do something insecure if the
- sandbox is enabled.
- """
-
-
class TemplateNotFound(IOError, LookupError, TemplateError):
"""Raised if a template does not exist."""
@@ -37,9 +27,16 @@
def __init__(self, message, lineno, name=None, filename=None):
if name is not None:
- extra = '%s, line %d' % (name, lineno)
+ extra = '%s, line %d' % (name.encode('utf-8'), lineno)
else:
extra = 'line %d' % lineno
+ # if the message was provided as unicode we have to encode it
+ # to utf-8 explicitly
+ if isinstance(message, unicode):
+ message = message.encode('utf-8')
+ # otherwise make sure it's a in fact valid utf-8
+ else:
+ message = message.decode('utf-8', 'ignore').encode('utf-8')
TemplateError.__init__(self, '%s (%s)' % (message, extra))
self.message = message
self.lineno = lineno
@@ -50,15 +47,28 @@
class TemplateAssertionError(TemplateSyntaxError):
"""Like a template syntax error, but covers cases where something in the
template caused an error at compile time that wasn't necessarily caused
- by a syntax error.
+ by a syntax error. However it's a direct subclass of
+ :exc:`TemplateSyntaxError` and has the same attributes.
"""
class TemplateRuntimeError(TemplateError):
- """A runtime error."""
+ """A generic runtime error in the template engine. Under some situations
+ Jinja may raise this exception.
+ """
-class FilterArgumentError(Exception):
+class UndefinedError(TemplateRuntimeError):
+ """Raised if a template tries to operate on :class:`Undefined`."""
+
+
+class SecurityError(TemplateRuntimeError):
+ """Raised if a template tries to do something insecure if the
+ sandbox is enabled.
+ """
+
+
+class FilterArgumentError(TemplateRuntimeError):
"""This error is raised if a filter was called with inappropriate
arguments
"""