catchlib 1.0.4__tar.gz → 1.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {catchlib-1.0.4/src/catchlib.egg-info → catchlib-1.0.6}/PKG-INFO +1 -1
- {catchlib-1.0.4 → catchlib-1.0.6}/pyproject.toml +1 -1
- {catchlib-1.0.4 → catchlib-1.0.6}/src/catchlib/core/__init__.py +15 -17
- {catchlib-1.0.4 → catchlib-1.0.6/src/catchlib.egg-info}/PKG-INFO +1 -1
- {catchlib-1.0.4 → catchlib-1.0.6}/LICENSE.txt +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/MANIFEST.in +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/README.rst +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/setup.cfg +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/src/catchlib/__init__.py +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/src/catchlib/tests/__init__.py +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/src/catchlib/tests/test_0.py +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/src/catchlib.egg-info/SOURCES.txt +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/src/catchlib.egg-info/dependency_links.txt +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/src/catchlib.egg-info/requires.txt +0 -0
- {catchlib-1.0.4 → catchlib-1.0.6}/src/catchlib.egg-info/top_level.txt +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from contextlib import contextmanager
|
|
2
2
|
from typing import *
|
|
3
3
|
|
|
4
|
-
from overloadable import Overloadable
|
|
5
|
-
|
|
6
4
|
__all__ = ["Catcher"]
|
|
7
5
|
|
|
6
|
+
DEFAULT = object()
|
|
7
|
+
|
|
8
8
|
|
|
9
9
|
class Catcher:
|
|
10
10
|
"This class catches exceptions."
|
|
@@ -32,25 +32,23 @@ class Catcher:
|
|
|
32
32
|
"This property stores the caught exception."
|
|
33
33
|
return self._caught
|
|
34
34
|
|
|
35
|
-
@
|
|
36
|
-
def release(self: Self
|
|
37
|
-
"This method raises the caught exception."
|
|
38
|
-
return bool(len(args) + len(kwargs))
|
|
35
|
+
@overload
|
|
36
|
+
def release(self: Self) -> None: ...
|
|
39
37
|
|
|
40
|
-
@
|
|
41
|
-
def release(self: Self) -> None:
|
|
42
|
-
"This method raises the caught exception."
|
|
43
|
-
exc: BaseException
|
|
44
|
-
exc = self.caught
|
|
45
|
-
self._caught = None
|
|
46
|
-
if exc is not None:
|
|
47
|
-
raise exc
|
|
38
|
+
@overload
|
|
39
|
+
def release(self: Self, cause: Optional[BaseException]) -> None: ...
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
def release(
|
|
42
|
+
self: Self,
|
|
43
|
+
cause: BaseException | None | object = DEFAULT,
|
|
44
|
+
) -> None:
|
|
51
45
|
"This method raises the caught exception."
|
|
52
46
|
exc: BaseException
|
|
53
47
|
exc = self.caught
|
|
54
48
|
self._caught = None
|
|
55
|
-
if exc is
|
|
49
|
+
if exc is None:
|
|
50
|
+
return
|
|
51
|
+
if cause is DEFAULT:
|
|
52
|
+
raise exc
|
|
53
|
+
else:
|
|
56
54
|
raise exc from cause
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|