diff options
author | Federico Caselli <cfederico87@gmail.com> | 2021-11-21 21:17:27 +0100 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-24 22:51:27 -0500 |
commit | 31acba8ff7c123a20ae308b7f4ab6df3df264b48 (patch) | |
tree | a4c39a2123e1b95edf17995ba85bb69ee619f6e4 /lib/sqlalchemy/sql/elements.py | |
parent | d3a4e96196cd47858de072ae589c6554088edc24 (diff) | |
download | sqlalchemy-31acba8ff7c123a20ae308b7f4ab6df3df264b48.tar.gz |
Clean up most py3k compat
Change-Id: I8172fdcc3103ff92aa049827728484c8779af6b7
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index ca65f2112..76633cdd8 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -10,8 +10,6 @@ """ -from __future__ import unicode_literals - import itertools import operator import re @@ -3869,7 +3867,7 @@ class BinaryExpression(ColumnElement): ): # allow compatibility with libraries that # refer to BinaryExpression directly and pass strings - if isinstance(operator, util.string_types): + if isinstance(operator, str): operator = operators.custom_op(operator) self._orig = (left.__hash__(), right.__hash__()) self._propagate_attrs = left._propagate_attrs or right._propagate_attrs @@ -4638,10 +4636,7 @@ class NamedColumn(ColumnElement): @util.memoized_property def description(self): - if util.py3k: - return self.name - else: - return self.name.encode("ascii", "backslashreplace") + return self.name @HasMemoized.memoized_attribute def _tq_key_label(self): @@ -5068,7 +5063,7 @@ class ReleaseSavepointClause(_IdentifiedClause): __visit_name__ = "release_savepoint" -class quoted_name(util.MemoizedSlots, util.text_type): +class quoted_name(util.MemoizedSlots, str): """Represent a SQL identifier combined with quoting preferences. :class:`.quoted_name` is a Python unicode/str subclass which @@ -5138,19 +5133,19 @@ class quoted_name(util.MemoizedSlots, util.text_type): return self def __reduce__(self): - return quoted_name, (util.text_type(self), self.quote) + return quoted_name, (str(self), self.quote) def _memoized_method_lower(self): if self.quote: return self else: - return util.text_type(self).lower() + return str(self).lower() def _memoized_method_upper(self): if self.quote: return self else: - return util.text_type(self).upper() + return str(self).upper() def _find_columns(clause): @@ -5238,7 +5233,7 @@ class _truncated_label(quoted_name): return super(_truncated_label, cls).__new__(cls, value, quote) def __reduce__(self): - return self.__class__, (util.text_type(self), self.quote) + return self.__class__, (str(self), self.quote) def apply_map(self, map_): return self @@ -5324,26 +5319,26 @@ class _anonymous_label(_truncated_label): def __add__(self, other): if "%" in other and not isinstance(other, _anonymous_label): - other = util.text_type(other).replace("%", "%%") + other = str(other).replace("%", "%%") else: - other = util.text_type(other) + other = str(other) return _anonymous_label( quoted_name( - util.text_type.__add__(self, other), + str.__add__(self, other), self.quote, ) ) def __radd__(self, other): if "%" in other and not isinstance(other, _anonymous_label): - other = util.text_type(other).replace("%", "%%") + other = str(other).replace("%", "%%") else: - other = util.text_type(other) + other = str(other) return _anonymous_label( quoted_name( - util.text_type.__add__(other, self), + str.__add__(other, self), self.quote, ) ) |