Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.13] gh-125514: fix bug in test_traceback utility. Specify exception types in except: clauses (GH-125516) #125524

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Lib/test/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_no_caret_with_no_debug_ranges_flag_python_traceback(self):
import traceback
try:
x = 1 / 0
except:
except ZeroDivisionError:
traceback.print_exc()
""")
try:
Expand Down Expand Up @@ -550,9 +550,10 @@ class PurePythonExceptionFormattingMixin:
def get_exception(self, callable, slice_start=0, slice_end=-1):
try:
callable()
self.fail("No exception thrown.")
except:
except BaseException:
return traceback.format_exc().splitlines()[slice_start:slice_end]
else:
self.fail("No exception thrown.")

callable_line = get_exception.__code__.co_firstlineno + 2

Expand Down Expand Up @@ -2234,7 +2235,7 @@ def test_context_suppression(self):
try:
try:
raise Exception
except:
except Exception:
raise ZeroDivisionError from None
except ZeroDivisionError as _:
e = _
Expand Down Expand Up @@ -2586,9 +2587,9 @@ def exc():
try:
try:
raise EG("eg1", [ValueError(1), TypeError(2)])
except:
except EG:
raise EG("eg2", [ValueError(3), TypeError(4)])
except:
except EG:
raise ImportError(5)

expected = (
Expand Down Expand Up @@ -2638,7 +2639,7 @@ def exc():
except Exception as e:
exc = e
raise EG("eg", [VE(1), exc, VE(4)])
except:
except EG:
raise EG("top", [VE(5)])

expected = (f' + Exception Group Traceback (most recent call last):\n'
Expand Down Expand Up @@ -3451,7 +3452,7 @@ def test_long_context_chain(self):
def f():
try:
1/0
except:
except ZeroDivisionError:
f()

try:
Expand Down Expand Up @@ -3555,7 +3556,7 @@ def test_comparison_params_variations(self):
def raise_exc():
try:
raise ValueError('bad value')
except:
except ValueError:
raise

def raise_with_locals():
Expand Down
Loading