Skip to content

Commit b5fcfa7

Browse files
committed
Keep lines less than 80 chars
1 parent 79094f6 commit b5fcfa7

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

Lib/test/test_exception_group.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,26 @@ class MyEG(ExceptionGroup):
213213
eg = BaseExceptionGroup('test', excs)
214214

215215
# Ensure that immutable sequences still work fine.
216-
self.assertEqual(repr(eg), "BaseExceptionGroup('test', (ValueError(1), KeyboardInterrupt(2)))")
216+
self.assertEqual(
217+
repr(eg),
218+
"BaseExceptionGroup('test', (ValueError(1), KeyboardInterrupt(2)))"
219+
)
217220

218221
# Test non-standard custom sequences.
219222
excs = collections.deque([ValueError(1), TypeError(2)])
220223
eg = ExceptionGroup('test', excs)
221224

222-
self.assertEqual(repr(eg), "ExceptionGroup('test', deque([ValueError(1), TypeError(2)]))")
225+
self.assertEqual(
226+
repr(eg),
227+
"ExceptionGroup('test', deque([ValueError(1), TypeError(2)]))"
228+
)
223229
excs.clear()
224230

225231
# Ensure that clearing the exceptions sequence doesn't change the repr.
226-
self.assertEqual(repr(eg), "ExceptionGroup('test', deque([ValueError(1), TypeError(2)]))")
232+
self.assertEqual(
233+
repr(eg),
234+
"ExceptionGroup('test', deque([ValueError(1), TypeError(2)]))"
235+
)
227236

228237
def test_repr_raises(self):
229238
class MySeq(collections.abc.Sequence):
@@ -243,7 +252,10 @@ def __repr__(self):
243252
raise self.raises
244253
return None
245254

246-
with self.assertRaisesRegex(TypeError, r".*MySeq\.__repr__\(\) must return a str, not NoneType"):
255+
with self.assertRaisesRegex(
256+
TypeError,
257+
r".*MySeq\.__repr__\(\) must return a str, not NoneType"
258+
):
247259
ExceptionGroup("test", MySeq(None))
248260

249261
with self.assertRaises(ValueError):

Objects/exceptions.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,11 +1092,10 @@ BaseExceptionGroup_repr(PyObject *op)
10921092
if (!self->excs_str) {
10931093
assert(self->excs);
10941094

1095-
/* Older versions of this code delegated to BaseException's repr, inserting
1096-
* the current value of self.args[1]. However, mutating that sequence makes
1097-
* the repr appear as if the ExceptionGroup itself has changed, which it hasn't.
1098-
* So we use the actual exceptions tuple for accuracy, but make it look like the
1099-
* original exception sequence if possible, for backwards compatibility. */
1095+
/* Older versions delegated to BaseException, inserting the current
1096+
* value of self.args[1]; but this can be mutable and go out-of-sync
1097+
* with self.exceptions. Instead, use self.exceptions for accuracy,
1098+
* making it look like self.args[1] for backwards compatibility. */
11001099
if (PyList_Check(PyTuple_GET_ITEM(self->args, 1))) {
11011100
PyObject *exceptions_list = PySequence_List(self->excs);
11021101
if (!exceptions_list) {

0 commit comments

Comments
 (0)