From 03e47a8255476d9ed50c5aec73e6c272761d67eb Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 22 Aug 2015 16:01:23 -0400 Subject: - repair the inspection hook in sqltypes to not be fooled by mock and other __getattr__ impostors --- lib/sqlalchemy/sql/sqltypes.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index b5c575143..92a0628da 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -1745,7 +1745,12 @@ def _resolve_value_to_type(value): # use inspect() to detect SQLAlchemy built-in # objects. insp = inspection.inspect(value, False) - if insp is not None: + if ( + insp is not None and + # foil mock.Mock() and other impostors by ensuring + # the inspection target itself self-inspects + insp.__class__ in inspection._registrars + ): raise exc.ArgumentError( "Object %r is not legal as a SQL literal value" % value) return NULLTYPE -- cgit v1.2.1