https://github.com/python/cpython/commit/f2d6f57178ee7ade43f180dc000bd193606d3bc1
commit: f2d6f57178ee7ade43f180dc000bd193606d3bc1
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: encukou <[email protected]>
date: 2025-12-17T11:28:42+01:00
summary:

[3.14] gh-139320: Cover exception chaining in the docs of 
`contextmanager.__exit__` (GH-140169) (GH-142792)

(cherry picked from commit a44509ea87021f78a9f769aff2bb3fc212bc8afc)

Co-authored-by: Bartosz SÅ‚awecki <[email protected]>

files:
M Doc/library/stdtypes.rst

diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 2a31bc04f6393f..0036b198330ff6 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -5461,9 +5461,11 @@ before the statement body is executed and exited when 
the statement ends:
    Returning a true value from this method will cause the :keyword:`with` 
statement
    to suppress the exception and continue execution with the statement 
immediately
    following the :keyword:`!with` statement. Otherwise the exception continues
-   propagating after this method has finished executing. Exceptions that occur
-   during execution of this method will replace any exception that occurred in 
the
-   body of the :keyword:`!with` statement.
+   propagating after this method has finished executing.
+
+   If this method raises an exception while handling an earlier exception from 
the
+   :keyword:`with` block, the new exception is raised, and the original 
exception
+   is stored in its :attr:`~BaseException.__context__` attribute.
 
    The exception passed in should never be reraised explicitly - instead, this
    method should return a false value to indicate that the method completed

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to