diff --git a/Fix-a-regression-in-traceback-print_exception.patch b/Fix-a-regression-in-traceback-print_exception.patch new file mode 100644 index 0000000000000000000000000000000000000000..3cfd3360481f75a5c3f3b3e7718a6070b8297123 --- /dev/null +++ b/Fix-a-regression-in-traceback-print_exception.patch @@ -0,0 +1,62 @@ +From 2218e9cf14069d804da2f50db8e85fc6648638f3 Mon Sep 17 00:00:00 2001 +From: Berker Peksag +Date: Fri, 24 Jul 2015 17:36:21 +0300 +Subject: [PATCH] Issue #24695: Fix a regression in traceback.print_exception() + +If exc_traceback is None we shouldn't print a traceback header +like described in the documentation. +--- + AUTHORS | 1 + + traceback2/__init__.py | 4 +++- + traceback2/tests/test_traceback.py | 6 ++++++ + 3 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/AUTHORS b/AUTHORS +index ad86f89..91a946e 100644 +--- a/AUTHORS ++++ b/AUTHORS +@@ -1 +1,2 @@ + Robert Collins ++Berker Peksag +diff --git a/traceback2/__init__.py b/traceback2/__init__.py +index 88fcaaf..7fdeb36 100644 +--- a/traceback2/__init__.py ++++ b/traceback2/__init__.py +@@ -465,6 +465,7 @@ class TracebackException: + _seen=_seen) + else: + context = None ++ self.exc_traceback = exc_traceback + self.__cause__ = cause + self.__context__ = context + self.__suppress_context__ = \ +@@ -590,7 +591,8 @@ class TracebackException: + for line in self.__context__.format(chain=chain): + yield line + yield _context_message +- yield u('Traceback (most recent call last):\n') ++ if self.exc_traceback is not None: ++ yield u('Traceback (most recent call last):\n') + for line in self.stack.format(): + yield line + for line in self.format_exception_only(): +diff --git a/traceback2/tests/test_traceback.py b/traceback2/tests/test_traceback.py +index 2a933b5..3430a4d 100644 +--- a/traceback2/tests/test_traceback.py ++++ b/traceback2/tests/test_traceback.py +@@ -793,6 +793,12 @@ class TestTracebackException(unittest.TestCase): + exc = traceback.TracebackException(Exception, e, tb) + self.assertEqual(exc.stack[0].locals, None) + ++ def test_traceback_header(self): ++ # do not print a traceback header if exc_traceback is None ++ # see issue #24695 ++ exc = traceback.TracebackException(Exception, Exception("haven"), None) ++ self.assertEqual(list(exc.format()), [u("Exception: haven\n")]) ++ + def test_syntax_no_extras(self): + linecache.updatecache('/foo.py', fake_module) + e = SyntaxError("uh oh") +-- +2.39.0.windows.2 + diff --git a/python-traceback2.spec b/python-traceback2.spec index 41a6cceb5c62dc72094669745b441b5a4b245115..8887d6cac422a5a1df91cf8112f030a21d39e981 100644 --- a/python-traceback2.spec +++ b/python-traceback2.spec @@ -1,10 +1,11 @@ Name: python-traceback2 Version: 1.4.0 -Release: 20 +Release: 21 Summary: Backport of the traceback module License: Python URL: https://github.com/testing-cabal/traceback2 Source0: https://pypi.python.org/packages/source/t/traceback2/traceback2-%{version}.tar.gz +Patch0000: Fix-a-regression-in-traceback-print_exception.patch BuildArch: noarch BuildRequires: python3-pbr python3-devel @@ -24,6 +25,7 @@ A backport of traceback to older supported Pythons. %setup -qc mv traceback2-%{version} python3 mv python3/traceback2/tests . +%autopatch -p1 %build cd python3 @@ -40,6 +42,9 @@ cd .. %{python3_sitelib}/* %changelog +* Sat Jan 7 2023 zhangliangpengkun - 1.4.0-21 +- Fix a regression in traceback.print_exception + * Tue Aug 11 2020 zhangjiapeng - 1.4.0-20 - Remove python2-traceback2 subpackage