diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2021-10-30 22:00:25 +0200 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-01 15:11:25 -0400 |
| commit | 36e7aebd8d6faac77570403e99f9aa7b2330fa59 (patch) | |
| tree | f45950f61a4b27f128518be52157021ca4f4e8f7 /lib/sqlalchemy/sql | |
| parent | a99ea884403de1e1f762e9b1eb635d7fc6ef8e6f (diff) | |
| download | sqlalchemy-36e7aebd8d6faac77570403e99f9aa7b2330fa59.tar.gz | |
First round of removal of python 2
References: #4600
Change-Id: I61e35bc93fe95610ae75b31c18a3282558cd4ffe
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 1 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/elements.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/operators.py | 27 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 31 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/type_api.py | 7 |
5 files changed, 10 insertions, 65 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 7a2333d91..bcede5d76 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -175,7 +175,6 @@ OPERATORS = { operators.add: " + ", operators.mul: " * ", operators.sub: " - ", - operators.div: " / ", operators.mod: " % ", operators.truediv: " / ", operators.neg: "-", diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index e883454de..f1fe46fd2 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -5158,15 +5158,6 @@ class quoted_name(util.MemoizedSlots, util.text_type): else: return util.text_type(self).upper() - def __repr__(self): - if util.py2k: - backslashed = self.encode("ascii", "backslashreplace") - if not util.py2k: - backslashed = backslashed.decode("ascii") - return "'%s'" % backslashed - else: - return str.__repr__(self) - def _find_columns(clause): """locate Column objects within the given expression.""" diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index 695e086b8..b64bea07a 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -33,12 +33,6 @@ from operator import truediv from .. import util -if util.py2k: - from operator import div -else: - div = truediv - - class Operators(object): """Base of comparison and logical operators. @@ -1130,14 +1124,6 @@ class ColumnOperators(Operators): """ return self.reverse_operate(mul, other) - def __rdiv__(self, other): - """Implement the ``/`` operator in reverse. - - See :meth:`.ColumnOperators.__div__`. - - """ - return self.reverse_operate(div, other) - def __rmod__(self, other): """Implement the ``%`` operator in reverse. @@ -1223,14 +1209,6 @@ class ColumnOperators(Operators): """ return self.operate(mul, other) - def __div__(self, other): - """Implement the ``/`` operator. - - In a column context, produces the clause ``a / b``. - - """ - return self.operate(div, other) - def __mod__(self, other): """Implement the ``%`` operator. @@ -1240,7 +1218,7 @@ class ColumnOperators(Operators): return self.operate(mod, other) def __truediv__(self, other): - """Implement the ``//`` operator. + """Implement the ``/`` operator. In a column context, produces the clause ``a / b``. @@ -1248,7 +1226,7 @@ class ColumnOperators(Operators): return self.operate(truediv, other) def __rtruediv__(self, other): - """Implement the ``//`` operator in reverse. + """Implement the ``/`` operator in reverse. See :meth:`.ColumnOperators.__truediv__`. @@ -1610,7 +1588,6 @@ _PRECEDENCE = { json_path_getitem_op: 15, mul: 8, truediv: 8, - div: 8, mod: 8, neg: 8, add: 7, diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index ae589d648..77af76d0b 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -555,7 +555,6 @@ class Integer(_LookupExpressionAdapter, TypeEngine): Integer: self.__class__, Numeric: Numeric, }, - operators.div: {Integer: self.__class__, Numeric: Numeric}, operators.truediv: {Integer: self.__class__, Numeric: Numeric}, operators.sub: {Integer: self.__class__, Numeric: Numeric}, } @@ -753,7 +752,6 @@ class Numeric(_LookupExpressionAdapter, TypeEngine): Numeric: self.__class__, Integer: self.__class__, }, - operators.div: {Numeric: self.__class__, Integer: self.__class__}, operators.truediv: { Numeric: self.__class__, Integer: self.__class__, @@ -985,20 +983,13 @@ class _Binary(TypeEngine): # Python 3 has native bytes() type # both sqlite3 and pg8000 seem to return it, # psycopg2 as of 2.5 returns 'memoryview' - if util.py2k: - - def result_processor(self, dialect, coltype): - return processors.to_str - - else: - - def result_processor(self, dialect, coltype): - def process(value): - if value is not None: - value = bytes(value) - return value + def result_processor(self, dialect, coltype): + def process(value): + if value is not None: + value = bytes(value) + return value - return process + return process def coerce_compared_value(self, op, value): """See :meth:`.TypeEngine.coerce_compared_value` for a description.""" @@ -1494,14 +1485,7 @@ class Enum(Emulated, String, SchemaType): self.validate_strings = kw.pop("validate_strings", False) if convert_unicode is None: - for e in self.enums: - # this is all py2k logic that can go away for py3k only, - # "expect unicode" will always be implicitly true - if isinstance(e, util.text_type): - _expect_unicode = True - break - else: - _expect_unicode = False + _expect_unicode = True else: _expect_unicode = convert_unicode @@ -2011,7 +1995,6 @@ class _AbstractInterval(_LookupExpressionAdapter, TypeEngine): operators.sub: {Interval: self.__class__}, operators.mul: {Numeric: self.__class__}, operators.truediv: {Numeric: self.__class__}, - operators.div: {Numeric: self.__class__}, } @property diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py index 2a4688bcc..f58851268 100644 --- a/lib/sqlalchemy/sql/type_api.py +++ b/lib/sqlalchemy/sql/type_api.py @@ -800,12 +800,7 @@ class TypeEngine(Traversible): return default.StrCompileDialect() def __str__(self): - if util.py2k: - return unicode(self.compile()).encode( # noqa - "ascii", "backslashreplace" - ) # noqa - else: - return str(self.compile()) + return str(self.compile()) def __repr__(self): return util.generic_repr(self) |
