Skip to content

Commit 3dab401

Browse files
committed
fix: Adapt psycopg2 to Python >= 3.13.11 (trixie)
Signed-off-by: Cagri Yonca <cagri@ibm.com>
1 parent f9582be commit 3dab401

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/instana/instrumentation/psycopg2.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ def register_json_with_instana(
4141
args: Tuple[Any, ...],
4242
kwargs: Dict[str, Any],
4343
) -> Callable[..., object]:
44+
args_list = list(args)
45+
4446
if "conn_or_curs" in kwargs and hasattr(kwargs["conn_or_curs"], "__wrapped__"):
4547
kwargs["conn_or_curs"] = kwargs["conn_or_curs"].__wrapped__
48+
elif len(args_list) > 0 and hasattr(args_list[0], "__wrapped__"):
49+
args_list[0] = args_list[0].__wrapped__
50+
args = tuple(args_list)
4651

4752
return wrapped(*args, **kwargs)
4853

tests/clients/test_psycopg2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
import psycopg2
99
import psycopg2.extensions as ext
1010
import psycopg2.extras
11+
import psycopg2._json
1112
import pytest
1213

13-
from instana.instrumentation.psycopg2 import register_json_with_instana
14+
1415
from instana.singletons import agent, get_tracer
1516
from tests.helpers import testenv
1617

@@ -65,7 +66,7 @@ def _resource(self) -> Generator[None, None, None]:
6566
agent.options.allow_exit_as_root = False
6667

6768
def test_register_json(self) -> None:
68-
resp = register_json_with_instana(conn_or_curs=self.db)
69+
resp = psycopg2._json.register_json(conn_or_curs=self.db)
6970
assert resp[0].values[0] == 114
7071
assert resp[1].values[0] == 199
7172

0 commit comments

Comments
 (0)