Added comment to why __unicode__ goes after __str__.
authorArmin Ronacher <armin.ronacher@active-4.com>
Tue, 9 Feb 2010 23:07:43 +0000 (00:07 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Tue, 9 Feb 2010 23:07:43 +0000 (00:07 +0100)
--HG--
branch : trunk

jinja2/environment.py
jinja2/exceptions.py
jinja2/runtime.py

index 965b0582349e21ba2bb33b95454a155f2a0358cf..fe7ed02336a494c7a7a9bfa436db38b3bb9cbe3e 100644 (file)
@@ -814,6 +814,10 @@ class TemplateModule(object):
     def __str__(self):
         return unicode(self).encode('utf-8')
 
+    # unicode goes after __str__ because we configured 2to3 to rename
+    # __unicode__ to __str__.  because the 2to3 tree is not designed to
+    # remove nodes from it, we leave the above __str__ around and let
+    # it override at runtime.
     def __unicode__(self):
         return concat(self._body_stream)
 
index 4df8324d3350c699ae6cec428bb866b86d0907e3..69a877ba3b0be87d08bbb44c72efd189334b22f1 100644 (file)
@@ -44,6 +44,10 @@ class TemplateNotFound(IOError, LookupError, TemplateError):
     def __str__(self):
         return self.message.encode('utf-8')
 
+    # unicode goes after __str__ because we configured 2to3 to rename
+    # __unicode__ to __str__.  because the 2to3 tree is not designed to
+    # remove nodes from it, we leave the above __str__ around and let
+    # it override at runtime.
     def __unicode__(self):
         return self.message
 
@@ -81,6 +85,10 @@ class TemplateSyntaxError(TemplateError):
     def __str__(self):
         return unicode(self).encode('utf-8')
 
+    # unicode goes after __str__ because we configured 2to3 to rename
+    # __unicode__ to __str__.  because the 2to3 tree is not designed to
+    # remove nodes from it, we leave the above __str__ around and let
+    # it override at runtime.
     def __unicode__(self):
         # for translated errors we only return the message
         if self.translated:
index ae394e377a39479992d8898edeec638fae27edbc..be5b09a02e71febc499749785e00f5450420ec12 100644 (file)
@@ -454,6 +454,10 @@ class Undefined(object):
     def __str__(self):
         return unicode(self).encode('utf-8')
 
+    # unicode goes after __str__ because we configured 2to3 to rename
+    # __unicode__ to __str__.  because the 2to3 tree is not designed to
+    # remove nodes from it, we leave the above __str__ around and let
+    # it override at runtime.
     def __unicode__(self):
         return u''