summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/contextlib.py
diff options
context:
space:
mode:
authorAlexSm <[email protected]>2024-02-16 11:51:30 +0100
committerGitHub <[email protected]>2024-02-16 11:51:30 +0100
commit506ecaee93b52cc12c2e2f97c3d42e3ca2a7f59e (patch)
treed096fb9eb988fbb0ca1ba970041773207ce3aa70 /contrib/tools/python3/src/Lib/contextlib.py
parent4749b9e5d260714490997e6f5ee1ee8c1c8fc46c (diff)
parentf200f72c9d7a89c1018e3dc6b46c49fe2ecf84fb (diff)
Merge pull request #1940 from dcherednik/importlib
Library import 14
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: