Blob Blame History Raw
Index: CHANGES
===================================================================
--- CHANGES	(revision 418:a1a4cc82d055)
+++ CHANGES	(revision 421:1edffe555b6a)
@@ -1,2 +1,8 @@
+0.3.3
+- Fixed sometimes incorrect usage of 
+  exc.__class__.__name__
+  in html/text error templates when using 
+  Python 2.4 [ticket:131]
+  
 0.3.2
 - Calling a def from the top, via 
Index: mako/__init__.py
===================================================================
--- mako/__init__.py	(revision 418:a1a4cc82d055)
+++ mako/__init__.py	(revision 421:1edffe555b6a)
@@ -6,4 +6,4 @@
 
 
-__version__ = '0.3.2'
+__version__ = '0.3.3'
 
Index: mako/exceptions.py
===================================================================
--- mako/exceptions.py	(revision 404:1cd41f35ac44)
+++ mako/exceptions.py	(revision 421:1edffe555b6a)
@@ -60,13 +60,18 @@
     error - the exception instance.  
     message - the exception error message as unicode
-    source - source code of the file where the error occured.  if the error occured within a compiled template,
-    this is the template source.
-    lineno - line number where the error occured.  if the error occured within a compiled template, the line number
-    is adjusted to that of the template source
-    records - a list of 8-tuples containing the original python traceback elements, plus the 
-    filename, line number, source line, and full template source for the traceline mapped back to its originating source
-    template, if any for that traceline (else the fields are None).
+    source - source code of the file where the error occured.  
+        if the error occured within a compiled template,
+        this is the template source.
+    lineno - line number where the error occured.  if the error 
+        occured within a compiled template, the line number
+        is adjusted to that of the template source
+    records - a list of 8-tuples containing the original 
+        python traceback elements, plus the 
+    filename, line number, source line, and full template source 
+        for the traceline mapped back to its originating source
+        template, if any for that traceline (else the fields are None).
     reverse_records - the list of records in reverse
-    traceback - a list of 4-tuples, in the same format as a regular python traceback, with template-corresponding 
+    traceback - a list of 4-tuples, in the same format as a regular 
+        python traceback, with template-corresponding 
     traceback records replacing the originals
     reverse_traceback - the traceback list in reverse
@@ -95,5 +100,9 @@
             
         self._init_message()
-
+    
+    @property
+    def errorname(self):
+        return util.exception_name(self.error)
+        
     def _init_message(self):
         """Find a unicode representation of self.error"""
@@ -230,5 +239,5 @@
     ${line | unicode.strip}
 % endfor
-${str(tback.error.__class__.__name__)}: ${tback.message}
+${tback.errorname}: ${tback.message}
 """)
 
@@ -281,5 +290,5 @@
         lines = None
 %>
-<h3>${str(tback.error.__class__.__name__)}: ${tback.message}</h3>
+<h3>${tback.errorname}: ${tback.message}</h3>
 
 % if lines:
Index: mako/util.py
===================================================================
--- mako/util.py	(revision 402:44fe48f610d3)
+++ mako/util.py	(revision 421:1edffe555b6a)
@@ -9,4 +9,5 @@
 
 py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0)
+py24 = sys.version_info >= (2, 4) and sys.version_info < (2, 5)
 jython = sys.platform.startswith('java')
 win32 = sys.platform.startswith('win')
@@ -43,5 +44,15 @@
     fn.__name__ = name
     return fn
-   
+ 
+if py24:
+    def exception_name(exc):
+        try:
+            return exc.__class__.__name__
+        except AttributeError:
+            return exc.__name__
+else:
+    def exception_name(exc):
+        return exc.__class__.__name__
+    
 def verify_directory(dir):
     """create and/or verify a filesystem directory."""