From 20e6c915a79fc2c2b33cd3ea7f567d859d879893 Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Mon, 11 May 2026 18:43:17 +0800 Subject: [PATCH 1/3] Fix typo in compound_stmts.rst --- Doc/reference/compound_stmts.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index a819c41d834aa7..275835facafc32 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -294,9 +294,8 @@ was translated to :: This means the exception must be assigned to a different name to be able to refer to it after the :keyword:`!except` clause. -Exceptions are cleared because with the -traceback attached to them, they form a reference cycle with the stack frame, -keeping all locals in that frame alive until the next garbage collection occurs. +Exceptions are cleared because their attached tracebacks form a reference cycle with the stack +frame, keeping all locals in that frame alive until the next garbage collection occurs. .. index:: pair: module; sys @@ -341,7 +340,7 @@ can have either :keyword:`except` or :keyword:`!except*` clauses, but not both. The exception type for matching is mandatory in the case of :keyword:`!except*`, so ``except*:`` is a syntax error. The type is interpreted as in the case of :keyword:`!except`, but matching is performed on the exceptions contained in the -group that is being handled. An :exc:`TypeError` is raised if a matching +group that is being handled. A :exc:`TypeError` is raised if a matching type is a subclass of :exc:`!BaseExceptionGroup`, because that would have ambiguous semantics. From 5fa04e50dbfe2fbde581b20409cee7f21afa419d Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sun, 5 Jul 2026 18:01:06 +0800 Subject: [PATCH 2/3] Revert --- Doc/reference/compound_stmts.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 275835facafc32..fe60c6e51c4100 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -294,8 +294,9 @@ was translated to :: This means the exception must be assigned to a different name to be able to refer to it after the :keyword:`!except` clause. -Exceptions are cleared because their attached tracebacks form a reference cycle with the stack -frame, keeping all locals in that frame alive until the next garbage collection occurs. +Exceptions are cleared because with the +traceback attached to them, they form a reference cycle with the stack frame, +keeping all locals in that frame alive until the next garbage collection occurs. .. index:: pair: module; sys From 86bfba55c39478d7f488117a86073e4df978f8e3 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Sun, 5 Jul 2026 13:10:07 +0200 Subject: [PATCH 3/3] Minor issues --- Doc/reference/compound_stmts.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index fe60c6e51c4100..46190dd060664f 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -279,12 +279,12 @@ and the exception occurs in the :keyword:`!try` clause of the inner handler, the outer handler will not handle the exception.) When an exception has been assigned using ``as target``, it is cleared at the -end of the :keyword:`!except` clause. This is as if :: +end of the :keyword:`!except` clause. This is as if:: except E as N: foo -was translated to :: +was translated to:: except E as N: try: @@ -357,7 +357,7 @@ or the last :keyword:`!except*` clause has run. After all :keyword:`!except*` clauses execute, the group of unhandled exceptions is merged with any exceptions that were raised or re-raised from within -:keyword:`!except*` clauses. This merged exception group propagates on.:: +:keyword:`!except*` clauses. This merged exception group propagates on:: >>> try: ... raise ExceptionGroup("eg", @@ -1310,7 +1310,7 @@ mutable object, such as a list or a dictionary: if the function modifies the object (e.g. by appending an item to a list), the default parameter value is in effect modified. This is generally not what was intended. A way around this is to use ``None`` as the default, and explicitly test for it in the body of the function, -e.g.:: +for example:: def whats_on_the_telly(penguin=None): if penguin is None: