This repository was archived by the owner on Apr 10, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -337,13 +337,9 @@ print(
337337# [ValueError('a'), TypeError('b'), TypeError('c'), KeyError('d')]
338338```
339339
340- ### "raise e" vs "raise"
340+ ### "raise e" and "raise"
341341
342- The difference between bare ` raise ` and a more specific ` raise e ` is more
343- significant for exception groups than it is for regular exceptions. Consider
344- the following two examples that illustrate it.
345-
346- Bare ` raise ` preserves the exception group internal structure:
342+ There is no difference between bare ` raise ` and a more specific ` raise e ` :
347343
348344``` python
349345try :
356352 )
357353 )
358354except * TypeError as e:
359- raise
355+ raise # or "raise e"
360356
361357# would terminate with:
362358#
@@ -370,7 +366,11 @@ except *TypeError as e:
370366# )
371367```
372368
373- Whereas ` raise e ` would flatten the captured subset:
369+ It is important to point out that the ` ExceptionGroup ` bound to ` e ` is an
370+ ephemeral object. Raising it via ` raise ` or ` raise e ` will not cause changes
371+ to the overall shape of the ` ExceptionGroup ` . If the user wants to "flatten"
372+ the tree, they can explicitly create a new ` ExceptionGroup ` and raise it:
373+
374374
375375``` python
376376try :
383383 )
384384 )
385385except * TypeError as e:
386- raise e
386+ raise ExceptionGroup( * e)
387387
388388# would terminate with:
389389#
You can’t perform that action at this time.
0 commit comments