summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/automap.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-05-08 18:36:57 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-05-08 18:36:57 -0400
commit22570c3181ef4e98c548c2f6254a0c7585568f06 (patch)
tree471bc4670f0ac40c789a075f8797387ffb749041 /lib/sqlalchemy/ext/automap.py
parenta2e7b4c5fa71b95829e6d954f958bd91b4fd67e5 (diff)
downloadsqlalchemy-22570c3181ef4e98c548c2f6254a0c7585568f06.tar.gz
Protect against cls weakref becoming None
Protected against testing "None" as a class in the case where declarative classes are being garbage collected and new automap prepare() operations are taking place concurrently, very infrequently hitting a weakref that has not been fully acted upon after gc. Change-Id: I32e1dfc5ac46bac4127fe808cfd18368e2fad9dd
Diffstat (limited to 'lib/sqlalchemy/ext/automap.py')
-rw-r--r--lib/sqlalchemy/ext/automap.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py
index 14599fe5e..bd33ebde9 100644
--- a/lib/sqlalchemy/ext/automap.py
+++ b/lib/sqlalchemy/ext/automap.py
@@ -877,9 +877,9 @@ def _relationships_for_fks(automap_base, map_config, table_to_map_config,
name_for_collection_relationship,
generate_relationship):
local_table = map_config.local_table
- local_cls = map_config.cls
+ local_cls = map_config.cls # derived from a weakref, may be None
- if local_table is None:
+ if local_table is None or local_cls is None:
return
for constraint in local_table.constraints:
if isinstance(constraint, ForeignKeyConstraint):