Skip to content

Commit 40c0526

Browse files
github-actions[bot]emmettbutleravara1986
authored
fix: make Psycopg3TracedAsyncCursor implementation conform to its type hints [backport 1.20] (#7914)
Backport a254b7a from #7908 to 1.20. This pull request fixes #7900 by aligning `Psycopg3TracedAsyncCursor.__aexit__` with the method it wraps, `AsyncCursor.__aexit__`. It removes a return value that is sometimes non-`None`, breaking compatibility with psycopg3's interface. No regression test because this is a straightforward alignment of integration code with the integrated library's interface. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) - [x] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [x] This PR doesn't touch any of that. Co-authored-by: Emmett Butler <[email protected]> Co-authored-by: Alberto Vara <[email protected]>
1 parent 80dca21 commit 40c0526

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ddtrace/contrib/psycopg/async_cursor.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
1919
# previous versions of the dbapi didn't support context managers. let's
2020
# reference the func that would be called to ensure that errors
2121
# messages will be the same.
22-
await self.__wrapped__.__aexit__(exc_type, exc_val, exc_tb)
23-
24-
# and finally, yield the traced cursor.
25-
return self
22+
return await self.__wrapped__.__aexit__(exc_type, exc_val, exc_tb)
2623

2724

2825
class Psycopg3FetchTracedAsyncCursor(Psycopg3TracedAsyncCursor, dbapi_async.FetchTracedAsyncCursor):
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
psycopg: This fix resolves an issue where exceptions originating from asynchronous Psycopg cursors were not
5+
propagated up the call stack.

0 commit comments

Comments
 (0)