4

Understandably many of the tickets we file in Trac contain tracebacks. It would be excellent if these were nicely formatted and syntax highlighted.

I've conducted a cursory Google search for a Python traceback wiki processor and have not found any quick hits.

I'm happy to roll my own if anyone can recommend a traceback formatter (stand alone or embedded in an open source project) that outputs HTML/reStructuredText/etc.

brotchie
  • 491
  • 4
  • 10

3 Answers3

4

I don't believe you need that patch. You could specify the shortcode mapping in the trac.ini, but you can also (at least in trac 0.12) just use the mime type directly:

{{{
#!text/x-python-traceback
<traceback>
}}}

See more at http://trac.edgewall.org/wiki/TracSyntaxColoring. x-python-traceback isn't in the list there, but you'll get an error previewing if trac can't handle it and it WorkedForMe.

2

Pygments has support for syntax-coloring Python tracebacks, and there's a trac plugin, but the wiki page claims Trac 0.11 supports Pygments natively.

Ned Batchelder
  • 364,293
  • 75
  • 561
  • 662
2

Trac 0.11 supports Pygments but doesn't expose the pytb formatting type. Here's a patch against Trac 0.11.3 to add support for Python tracebacks.

diff -r 5a0c5e3255b4 mimeview/api.py
--- a/mimeview/api.py   Tue Aug 11 11:33:45 2009 +1000
+++ b/mimeview/api.py   Mon Aug 24 15:13:34 2009 +1000
@@ -348,6 +348,7 @@
     'text/x-perl':            ['pl', 'pm', 'PL', 'perl'],
     'text/x-php':             ['php', 'php3', 'php4'],
     'text/x-python':          ['py', 'python'],
+    'text/x-python-traceback':['pytb'],
     'text/x-pyrex':           ['pyx'],
     'text/x-ruby':            ['rb', 'ruby'],
     'text/x-scheme':          ['scm'],
brotchie
  • 491
  • 4
  • 10