|
Ran
|
Jobs
2
|
Files
8
|
Run time
1min
|
Badge
README BADGES
|
push
github
fix: propagate exceptions in ClientManager.context/.acontext Raising `StopIteration` from a `finally` clause in a `contextlib.contextmanager` suppresses any Exceptions that occur in the `with` block. The most serious consquence of this bug in `sparqlx` is that `raise_for_status` in managed `httpx` clients gets suppressed. To understand the contextlib.contextmanager behavior, one needs to be aware of the following: - returning from a generator raises `StopIteration` - returning True from `__exit__` suppresses Exceptions that occur in the lexical context block; this behavior is intentional and documented, see [Context Managers](https://typing.python.org/en/latest/spec/exceptions.html#context-managers) in the Exceptions Docs. - `contextlib.contextmanager` needs to suppress `StopIteration` unless it is raised in the `with` block, see [contextlib.py, L163](https://github.com/python/cpython/blob/5b5263648/Lib/contextlib.py#L163). Since the `finally` clause in the generator-based context manager abstraction of `contextlib.contextmanager` represents the exit mechanism of a context manager, `StopIteration` gets raised in `__exit__` , which is a different case than handling `StopIteration` in `__exit__` when it was raised in `__enter__`. Note that `StopIteration` is raised in `sparqlx.utils.ClientManager` only for managed clients. This is also the reason, why `httpx.Client.raise_for_status` correctly propagates with user-provided clients! Closes #94.
295 of 295 relevant lines covered (100.0%)
2.0 hits per line
| ID | Job ID | Ran | Files | Coverage | |
|---|---|---|---|---|---|
| 1 | 20406522688.1 | 8 |
100.0 |
GitHub Action Run | |
| 2 | 20406522688.2 | 8 |
100.0 |
GitHub Action Run |
| Coverage | ∆ | File | Lines | Relevant | Covered | Missed | Hits/Line |
|---|