From 54a06cc2e84afd3f039cfb86b50928571dbdc86d Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 11 Aug 2019 20:44:42 -0400 Subject: [PATCH] Use compat.string_types to check for visit name string Th visitor optimization looking for plain string needs to accommodate for u"" in Python 2 due to the unicode_literals future. Fixes: #4800 Change-Id: I5e3136f2f2cbd5f24d89186b599f59ea2e7f1550 (cherry picked from commit 3a542005a5f38556dc45c5bc8f256a154ee72c8a) --- lib/sqlalchemy/sql/visitors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/sql/visitors.py b/lib/sqlalchemy/sql/visitors.py index c06c954596..0a3cb8c1cf 100644 --- a/lib/sqlalchemy/sql/visitors.py +++ b/lib/sqlalchemy/sql/visitors.py @@ -76,7 +76,8 @@ def _generate_dispatch(cls): """ if "__visit_name__" in cls.__dict__: visit_name = cls.__visit_name__ - if isinstance(visit_name, str): + + if isinstance(visit_name, util.compat.string_types): # There is an optimization opportunity here because the # the string name of the class's __visit_name__ is known at # this early stage (import time) so it can be pre-constructed. -- 2.47.2