]> git.ipfire.org Git - thirdparty/psycopg.git/commit
Don't look up other modules objects in __del__ methods
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 6 Jan 2022 16:09:22 +0000 (17:09 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 6 Jan 2022 21:49:20 +0000 (22:49 +0100)
commitf4ea31ca597926746d3fb3ca11697d3b2fa5fc70
tree1425e293e3493335282dd640a729296297f95eef
parent8be9776c3a59c2b5ceb5d2dfb4117fb9fa4717bf
Don't look up other modules objects in __del__ methods

The modules might have been already cleaned up during interpreted
shutdown. See <https://bugs.python.org/issue46256#msg409847> for an
explanation.

The stdlib guards against the same thing happening too. However they
take a reference in the function closure, which is stronger than what we
do. Doing so, on our strictly typed codebase, is a tedious chore, so, if
this is enough (it should be, according to the OP), I'm happy this way.

Close #198.
docs/news.rst
psycopg/psycopg/connection.py
psycopg/psycopg/pq/pq_ctypes.py
psycopg/psycopg/server_cursor.py