summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2023-04-12 20:10:13 +0200
committerGitHub <noreply@github.com>2023-04-12 20:10:13 +0200
commit50dd4d80e25c4c4afab503d41b471a536ed2af13 (patch)
tree023bdc3efb51d6a04baed31ce1b8aa95a47c448e
parent96a0cdf200ab8a36dc5f6f748f3b9d01c05cb91b (diff)
downloadpygments-git-50dd4d80e25c4c4afab503d41b471a536ed2af13.tar.gz
Python console: do not require output that looks like a traceback to be valid (#2410)
-rw-r--r--CHANGES6
-rw-r--r--pygments/lexers/python.py3
-rw-r--r--tests/snippets/pycon/multiple_tb.txt108
3 files changed, 115 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index d75828a2..1da4243d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,10 +3,13 @@ Pygments changelog
Pull request numbers before 2.4.2 are not linked as they refer to the now defunct Bitbucket project.
-Version 2.16.0
+Version 2.15.1
--------------
(unreleased)
+- Fix Python console traceback lexing being too strict (#2407)
+
+
Version 2.15.0
--------------
(released April 10th, 2023)
@@ -68,6 +71,7 @@ Version 2.15.0
for developing are now defined and run through tox. The ``doc`` folder
still contains a ``Makefile`` as an alternative to ``tox -e doc``.
+
Version 2.14.0
--------------
(released January 1st, 2023)
diff --git a/pygments/lexers/python.py b/pygments/lexers/python.py
index 6c89e6b5..eaaf6476 100644
--- a/pygments/lexers/python.py
+++ b/pygments/lexers/python.py
@@ -763,7 +763,8 @@ class PythonTracebackLexer(RegexLexer):
(r'^([^:]+)(: )(.+)(\n)',
bygroups(Generic.Error, Text, Name, Whitespace), '#pop'),
(r'^([a-zA-Z_][\w.]*)(:?\n)',
- bygroups(Generic.Error, Whitespace), '#pop')
+ bygroups(Generic.Error, Whitespace), '#pop'),
+ default('#pop'),
],
'markers': [
# Either `PEP 657 <https://www.python.org/dev/peps/pep-0657/>`
diff --git a/tests/snippets/pycon/multiple_tb.txt b/tests/snippets/pycon/multiple_tb.txt
new file mode 100644
index 00000000..c8b71fc0
--- /dev/null
+++ b/tests/snippets/pycon/multiple_tb.txt
@@ -0,0 +1,108 @@
+---input---
+>>> from multiprocessing import Pool
+>>> p = Pool(5)
+>>> def f(x):
+... return x*x
+...
+>>> with p:
+... p.map(f, [1,2,3])
+Process PoolWorker-1:
+Process PoolWorker-2:
+Process PoolWorker-3:
+Traceback (most recent call last):
+Traceback (most recent call last):
+Traceback (most recent call last):
+AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
+AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
+AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
+
+---tokens---
+'>>> ' Generic.Prompt
+'from' Keyword.Namespace
+' ' Text
+'multiprocessing' Name.Namespace
+' ' Text
+'import' Keyword.Namespace
+' ' Text
+'Pool' Name
+'\n' Text.Whitespace
+
+'>>> ' Generic.Prompt
+'p' Name
+' ' Text
+'=' Operator
+' ' Text
+'Pool' Name
+'(' Punctuation
+'5' Literal.Number.Integer
+')' Punctuation
+'\n' Text.Whitespace
+
+'>>> ' Generic.Prompt
+'def' Keyword
+' ' Text
+'f' Name.Function
+'(' Punctuation
+'x' Name
+')' Punctuation
+':' Punctuation
+'\n' Text.Whitespace
+
+'... ' Generic.Prompt
+' ' Text
+'return' Keyword
+' ' Text
+'x' Name
+'*' Operator
+'x' Name
+'\n' Text.Whitespace
+
+'...' Generic.Prompt
+'\n' Text.Whitespace
+
+'>>> ' Generic.Prompt
+'with' Keyword
+' ' Text
+'p' Name
+':' Punctuation
+'\n' Text.Whitespace
+
+'... ' Generic.Prompt
+' ' Text
+'p' Name
+'.' Operator
+'map' Name
+'(' Punctuation
+'f' Name
+',' Punctuation
+' ' Text
+'[' Punctuation
+'1' Literal.Number.Integer
+',' Punctuation
+'2' Literal.Number.Integer
+',' Punctuation
+'3' Literal.Number.Integer
+']' Punctuation
+')' Punctuation
+'\n' Text.Whitespace
+
+'Process PoolWorker-1:\n' Generic.Output
+
+'Process PoolWorker-2:\n' Generic.Output
+
+'Process PoolWorker-3:\n' Generic.Output
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+'AttributeError' Generic.Error
+': ' Text
+"Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>" Name
+'\n' Text.Whitespace
+
+"AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>\n" Generic.Output
+
+"AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>\n" Generic.Output