summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/contextlib.py
diff options
context:
space:
mode:
authorshadchin <[email protected]>2024-02-12 07:53:52 +0300
committerDaniil Cherednik <[email protected]>2024-02-14 14:26:16 +0000
commit31f2a419764a8ba77c2a970cfc80056c6cd06756 (patch)
treec1995d239eba8571cefc640f6648e1d5dd4ce9e2 /contrib/tools/python3/src/Lib/contextlib.py
parentfe2ef02b38d9c85d80060963b265a1df9f38c3bb (diff)
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Lib/contextlib.py')
-rw-r--r--contrib/tools/python3/src/Lib/contextlib.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/contrib/tools/python3/src/Lib/contextlib.py b/contrib/tools/python3/src/Lib/contextlib.py
index 4a338f5c637..b831d8916ca 100644
--- a/contrib/tools/python3/src/Lib/contextlib.py
+++ b/contrib/tools/python3/src/Lib/contextlib.py
@@ -155,7 +155,7 @@ class _GeneratorContextManager(
# tell if we get the same exception back
value = typ()
try:
- self.gen.throw(typ, value, traceback)
+ self.gen.throw(value)
except StopIteration as exc:
# Suppress StopIteration *unless* it's the same exception that
# was passed to throw(). This prevents a StopIteration
@@ -228,7 +228,7 @@ class _AsyncGeneratorContextManager(
# tell if we get the same exception back
value = typ()
try:
- await self.gen.athrow(typ, value, traceback)
+ await self.gen.athrow(value)
except StopAsyncIteration as exc:
# Suppress StopIteration *unless* it's the same exception that
# was passed to throw(). This prevents a StopIteration
@@ -453,7 +453,16 @@ class suppress(AbstractContextManager):
# exactly reproduce the limitations of the CPython interpreter.
#
# See http://bugs.python.org/issue12029 for more details
- return exctype is not None and issubclass(exctype, self._exceptions)
+ if exctype is None:
+ return
+ if issubclass(exctype, self._exceptions):
+ return True
+ if issubclass(exctype, BaseExceptionGroup):
+ match, rest = excinst.split(self._exceptions)
+ if rest is None:
+ return True
+ raise rest
+ return False
class _BaseExitStack: