Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b1afcb8
Use `self.exceptions` in `BaseExceptionGroup` repr by supporting cust…
dr-carlos Nov 19, 2025
59bc3c7
Update `ExceptionGroup` tests for new repr and add mutation test
dr-carlos Nov 19, 2025
ca2d21d
Fix typo in test comment
dr-carlos Nov 19, 2025
493ab01
Update docs for `BaseExceptionGroup` repr change
dr-carlos Nov 19, 2025
cd90d51
Add NEWS entry
dr-carlos Nov 19, 2025
177b535
Update `ExceptionGroup` repr in `test_traceback`
dr-carlos Nov 19, 2025
af4f086
Revert "Update `ExceptionGroup` repr in `test_traceback`"
dr-carlos Nov 21, 2025
72918ea
Update `ExceptionGroup` tests to no longer change the repr
dr-carlos Nov 21, 2025
b45402a
Store exceptions copy in `BaseExceptionGroup->excs_orig` and use in `…
dr-carlos Nov 21, 2025
62d72a4
Revert "Update docs for `BaseExceptionGroup` repr change"
dr-carlos Nov 21, 2025
f93ae8f
Remove `BaseExceptionGroup->excs_orig` and reconstruct in `repr` instead
dr-carlos Nov 21, 2025
56eefee
Ensure that the exceptions copy in `BaseExceptionGroup` repr is freed
dr-carlos Nov 21, 2025
79dd615
Move `ExceptionGroup` repr tests into new function
dr-carlos Nov 22, 2025
e9fec3d
Use the exceptions tuple for all non-lists in `ExceptionGroup` repr
dr-carlos Nov 22, 2025
f5acfef
Test custom sequence's `ExceptionGroup` repr
dr-carlos Nov 22, 2025
2fca592
Update code style in `exceptions.c`
dr-carlos Nov 22, 2025
4885a6b
Update code style in `exceptions.c`
dr-carlos Nov 22, 2025
4801399
Remove unused `name` variable with new `%Y` format
dr-carlos Nov 23, 2025
1bcddeb
Revert "Remove unused `name` variable with new `%Y` format"
dr-carlos Nov 23, 2025
ccef7c5
Revert "Update code style in `exceptions.c`"
dr-carlos Nov 23, 2025
9ca573e
Save repr of non-standard sequences in `BaseExceptionGroup` constructor
dr-carlos Nov 25, 2025
9531fe9
Update tests for non-standard exceptions sequence in `ExceptionGroup`
dr-carlos Nov 25, 2025
1da9238
Document implementation details for `ExceptionGroup` exception sequence
dr-carlos Nov 25, 2025
fcaf314
Update Misc/NEWS.d/next/Core_and_Builtins/2025-11-19-16-40-24.gh-issu…
iritkatriel Nov 26, 2025
2c67e71
Merge branch 'main' into exception-group-repr
iritkatriel Nov 26, 2025
d962581
Reword 'optimum' to 'optimal' in `exceptions.rst`
dr-carlos Nov 26, 2025
ce39eec
Update NEWS Entry
dr-carlos Nov 26, 2025
9211d01
Handle error on `__repr__` for exceptions sequence passed to `Excepti…
dr-carlos Nov 26, 2025
737206a
Change grammar in `exceptions.c`
dr-carlos Nov 26, 2025
8d17ef3
Update comment relating to `Py_XNewRef` in `BaseExceptionGroup_repr()`
dr-carlos Nov 26, 2025
383af2f
Handle `PySequence_List()` and `PyObject_Repr()` errors in `BaseExcep…
dr-carlos Nov 26, 2025
5353340
Conditionally use `Py_NewRef` in `BaseExceptionGroup_repr()`
dr-carlos Nov 26, 2025
9997c01
Refactor `goto error` into `return NULL` within `BaseExceptionGroup_r…
dr-carlos Nov 26, 2025
3cd38db
Test custom sequences which raise errors in the `ExceptionGroup()` co…
dr-carlos Nov 26, 2025
5feb970
Fix formatting of if-else in `exceptions.c`
dr-carlos Nov 26, 2025
d7aec51
Simplify f-string to normal str in `test_exceptions_mutation()`
dr-carlos Nov 26, 2025
e21fad0
Remove unnecessary `_exceptions_str` member of `ExceptionGroup`
dr-carlos Nov 26, 2025
79094f6
Fix if-else formatting in `exceptions.c`
dr-carlos Nov 26, 2025
b5fcfa7
Keep lines less than 80 chars
dr-carlos Nov 26, 2025
57f8bf6
Revert "Fix formatting of if-else in `exceptions.c`"
dr-carlos Nov 27, 2025
9cba6b6
Construct custom sequence outside of `assertRaises` context manager i…
dr-carlos Nov 27, 2025
d61e6b9
Swap order of if-else branches and clarify comment in `BaseExceptionG…
dr-carlos Nov 27, 2025
8e455fd
Merge branch 'main' into exception-group-repr
iritkatriel Dec 5, 2025
b75a12e
Merge branch 'main' into exception-group-repr
iritkatriel Dec 7, 2025
85cc2aa
Merge branch 'main' into exception-group-repr
iritkatriel Dec 7, 2025
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
Prev Previous commit
Next Next commit
Update ExceptionGroup tests to no longer change the repr
  • Loading branch information
dr-carlos committed Nov 21, 2025
commit 72918ead960e643aa76bfb43b27fa6a8fc1a9911
24 changes: 12 additions & 12 deletions Lib/test/test_exception_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_ExceptionGroup(self):

self.assertEqual(str(eg), "flat (2 sub-exceptions)")
self.assertEqual(repr(eg),
"ExceptionGroup('flat', (ValueError(1), TypeError(2)))")
"ExceptionGroup('flat', [ValueError(1), TypeError(2)])")

# Mutate the list of exceptions passed to BaseExceptionGroup.
# This shouldn't change the EG's functionality, nor its repr.
Expand All @@ -149,11 +149,11 @@ def test_ExceptionGroup(self):
self.assertEqual(str(eg), "nested (4 sub-exceptions)")
self.assertEqual(repr(eg),
"ExceptionGroup('nested', "
"(ExceptionGroup('flat', "
"(ValueError(1), TypeError(2))), "
"[ExceptionGroup('flat', "
"[ValueError(1), TypeError(2)]), "
"ValueError(1), "
"ExceptionGroup('flat', "
"(ValueError(1), TypeError(2))), TypeError(2)))")
"[ValueError(1), TypeError(2)]), TypeError(2)])")

def test_BaseExceptionGroup(self):
eg_excs = [ValueError(1), KeyboardInterrupt(2)]
Expand All @@ -164,7 +164,7 @@ def test_BaseExceptionGroup(self):
self.assertEqual(repr(eg),
"BaseExceptionGroup("
"'flat', "
"(ValueError(1), KeyboardInterrupt(2)))")
"[ValueError(1), KeyboardInterrupt(2)])")

# Mutate the list of exceptions passed to BaseExceptionGroup.
# This shouldn't change the EG's functionality, nor its repr.
Expand All @@ -176,11 +176,11 @@ def test_BaseExceptionGroup(self):
self.assertEqual(str(eg), "nested (3 sub-exceptions)")
self.assertEqual(repr(eg),
"BaseExceptionGroup('nested', "
"(BaseExceptionGroup('flat', "
"(ValueError(1), KeyboardInterrupt(2))), "
"[BaseExceptionGroup('flat', "
"[ValueError(1), KeyboardInterrupt(2)]), "
"ValueError(1), "
"BaseExceptionGroup('flat', "
"(ValueError(1), KeyboardInterrupt(2)))))")
"[ValueError(1), KeyboardInterrupt(2)])])")

def test_custom_exception(self):
class MyEG(ExceptionGroup):
Expand All @@ -191,7 +191,7 @@ class MyEG(ExceptionGroup):
'flat', eg_excs)

self.assertEqual(str(eg), "flat (2 sub-exceptions)")
self.assertEqual(repr(eg), "MyEG('flat', (ValueError(1), TypeError(2)))")
self.assertEqual(repr(eg), "MyEG('flat', [ValueError(1), TypeError(2)])")

# Mutate the list of exceptions passed to MyEG.
# This shouldn't change the EG's functionality, nor its repr.
Expand All @@ -203,10 +203,10 @@ class MyEG(ExceptionGroup):
self.assertEqual(str(eg), "nested (4 sub-exceptions)")
self.assertEqual(repr(eg), (
"MyEG('nested', "
"(MyEG('flat', (ValueError(1), TypeError(2))), "
"[MyEG('flat', [ValueError(1), TypeError(2)]), "
"ValueError(1), "
"MyEG('flat', (ValueError(1), TypeError(2))), "
"TypeError(2)))"))
"MyEG('flat', [ValueError(1), TypeError(2)]), "
"TypeError(2)])"))


def create_simple_eg():
Expand Down