PythonConsoleLexer is unable to parse full paths to excecptions

Issue #1483 new
Andy Freeland
created an issue

Also seen in https://github.com/sphinx-doc/sphinx/issues/2830

from pygments import highlight
from pygments.lexers import PythonConsoleLexer
from pygments.formatters import HtmlFormatter


pycon3 = PythonConsoleLexer(python3=True, stripnl=False)
pycon3.add_filter('raiseonerror')
formatter = HtmlFormatter()

source = """
>>> foo()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/saffy/Desktop/yarely-cookiecut/yarely/doctestsphinxtest.py", line 34, in foo
    raise b
yarely.doctestsphinxtest.FooError
"""

highlight(source, pycon3, formatter)  # => raises pygments.filters.ErrorToken
Traceback (most recent call last):
  File "test.py", line 19, in <module>
    highlight(source, pycon3, formatter)  # => raises pygments.filters.ErrorToken
  File "/Users/tkomiya/work/tmp/lib/python2.7/site-packages/pygments/__init__.py", line 87, in highlight
    return format(lex(code, lexer), formatter, outfile)
  File "/Users/tkomiya/work/tmp/lib/python2.7/site-packages/pygments/__init__.py", line 66, in format
    formatter.format(tokens, realoutfile)
  File "/Users/tkomiya/work/tmp/lib/python2.7/site-packages/pygments/formatter.py", line 95, in format
    return self.format_unencoded(tokensource, outfile)
  File "/Users/tkomiya/work/tmp/lib/python2.7/site-packages/pygments/formatters/html.py", line 850, in format_unencoded
    for t, piece in source:
  File "/Users/tkomiya/work/tmp/lib/python2.7/site-packages/pygments/formatters/html.py", line 690, in _wrap_div
    for tup in inner:
  File "/Users/tkomiya/work/tmp/lib/python2.7/site-packages/pygments/formatters/html.py", line 708, in _wrap_pre
    for tup in inner:
  File "/Users/tkomiya/work/tmp/lib/python2.7/site-packages/pygments/formatters/html.py", line 727, in _format_lines
    for ttype, value in tokensource:
  File "/Users/tkomiya/work/tmp/lib/python2.7/site-packages/pygments/filter.py", line 20, in _apply
    for token in filter_.filter(lexer, stream):
  File "/Users/tkomiya/work/tmp/lib/python2.7/site-packages/pygments/filters/__init__.py", line 196, in filter
    raise self.exception(value)
pygments.filters.ErrorToken: y

Comments (0)

  1. Log in to comment