Ticket #1852: template-print.diff

File template-print.diff, 839 bytes (added by anonymous, 19 years ago)
  • template/__init__.py

    old new  
    9090builtins = []
    9191
    9292class TemplateSyntaxError(Exception):
    93     pass
     93    def __str__(self):
     94        try:
     95            import cStringIO as StringIO
     96        except ImportError:
     97            import StringIO
     98        output = StringIO.StringIO()
     99        output.write(Exception.__str__(self))
     100        # Check if we wrapped an exception and print that too.
     101        if hasattr(self, 'exc_info'):
     102            import traceback
     103            output.write('\n\nOriginal ')
     104            e = self.exc_info
     105            traceback.print_exception(e[0], e[1], e[2], 500, output)
     106        return output.getvalue()
    94107
    95108class ContextPopException(Exception):
    96109    "pop() has been called more times than push()"
Back to Top