]> git.ipfire.org Git - thirdparty/psycopg.git/commit
fix(json): don't leak when lambdas are used as dumps/loads function
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 4 Jul 2025 18:00:43 +0000 (20:00 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 5 Jul 2025 17:01:24 +0000 (19:01 +0200)
commit72bf2a206ac4aec515e087de64f45557957f16f7
treece7ce9af95f726945239d93a713632443d1ade02
parent9d2b1c8c1d2114601038b8363a394f0ccaa4f9a7
fix(json): don't leak when lambdas are used as dumps/loads function

Cache functions on the code, not on the function identity itself:
different lambdas or local functions are different objects but he
underlying code object is the same.

Avoid caching if the function is a closure because it then becomes a can
of worms (if the argument is not hashable etc). Throw a warning in that
case.

Fix #1108

fix(json): don't leak when lambdas are used as loads function
docs/news.rst
psycopg/psycopg/types/json.py
tests/types/test_json.py