]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Handle case where InstanceState.obj returns None
authorFederico Caselli <cfederico87@gmail.com>
Tue, 6 Oct 2020 19:21:46 +0000 (21:21 +0200)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 7 Oct 2020 04:13:35 +0000 (00:13 -0400)
commit92db2a096b68d79e1b8d0ec4fa08e0efbd46700a
treeec9852de69fa1a56aa5c040d4c74953d2368021a
parentdfb94052675d39dba7ab443c49a2e7a3153bd89f
Handle case where InstanceState.obj returns None

Fixed bug where a call ``InstanceState.obj()`` could return None when
synchronizing the instance states of the objects in the session in case
they become out of scope but are not yet finalized by the gc. This
case does not happen in cPython, but it may present itself in pypy.

The approach is to allow None to be gracefully handled by the
evaluator itself, ensuring it returns None in all cases when None
is passed in.

Fixes: #5631
Change-Id: I53d38fbea2e72b2e677c6e7f70bf075a58e58945
lib/sqlalchemy/orm/evaluator.py
test/orm/test_evaluator.py