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/engine | |
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/engine')
-rw-r--r-- | lib/sqlalchemy/engine/default.py | 29 | ||||
-rw-r--r-- | lib/sqlalchemy/engine/reflection.py | 6 | ||||
-rw-r--r-- | lib/sqlalchemy/engine/result.py | 17 | ||||
-rw-r--r-- | lib/sqlalchemy/engine/url.py | 2 |
4 files changed, 3 insertions, 51 deletions
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index 373c90804..9ec6783b0 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -464,12 +464,7 @@ class DefaultDialect(interfaces.Dialect): return self.get_isolation_level(dbapi_conn) def _check_unicode_returns(self, connection, additional_tests=None): - # this now runs in py2k only and will be removed in 2.0; disabled for - # Python 3 in all cases under #5315 - if util.py2k and not self.supports_unicode_statements: - cast_to = util.binary_type - else: - cast_to = util.text_type + cast_to = util.text_type if self.positional: parameters = self.execute_sequence_format() @@ -523,12 +518,7 @@ class DefaultDialect(interfaces.Dialect): ) def _check_unicode_description(self, connection): - # all DBAPIs on Py2K return cursor.description as encoded - - if util.py2k and not self.supports_unicode_statements: - cast_to = util.binary_type - else: - cast_to = util.text_type + cast_to = util.text_type cursor = connection.connection.cursor() try: @@ -722,9 +712,6 @@ class DefaultDialect(interfaces.Dialect): def normalize_name(self, name): if name is None: return None - if util.py2k: - if isinstance(name, str): - name = name.decode(self.encoding) name_lower = name.lower() name_upper = name.upper() @@ -763,11 +750,6 @@ class DefaultDialect(interfaces.Dialect): self.identifier_preparer._requires_quotes )(name_lower): name = name_upper - if util.py2k: - if not self.supports_unicode_binds: - name = name.encode(self.encoding) - else: - name = unicode(name) # noqa return name def get_driver_connection(self, connection): @@ -968,12 +950,7 @@ class DefaultExecutionContext(interfaces.ExecutionContext): self.executemany = len(parameters) > 1 - # this must occur before create_cursor() since the statement - # has to be regexed in some cases for server side cursor - if util.py2k: - self.unicode_statement = util.text_type(compiled.string) - else: - self.unicode_statement = compiled.string + self.unicode_statement = compiled.string self.cursor = self.create_cursor() diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py index 21d68a1a2..fed353e9c 100644 --- a/lib/sqlalchemy/engine/reflection.py +++ b/lib/sqlalchemy/engine/reflection.py @@ -766,12 +766,6 @@ class Inspector(object): # returned them table._validate_dialect_kwargs(tbl_opts) - if util.py2k: - if isinstance(schema, str): - schema = schema.decode(dialect.encoding) - if isinstance(table_name, str): - table_name = table_name.decode(dialect.encoding) - found_table = False cols_by_orig_name = {} diff --git a/lib/sqlalchemy/engine/result.py b/lib/sqlalchemy/engine/result.py index 48572c7fe..dcf57f6e9 100644 --- a/lib/sqlalchemy/engine/result.py +++ b/lib/sqlalchemy/engine/result.py @@ -20,7 +20,6 @@ from ..sql.base import _generative from ..sql.base import HasMemoized from ..sql.base import InPlaceGenerative from ..util import collections_abc -from ..util import py2k if _baserow_usecext: @@ -658,7 +657,6 @@ class ResultInternal(InPlaceGenerative): class _WithKeys(object): # used mainly to share documentation on the keys method. - # py2k does not allow overriding the __doc__ attribute. def keys(self): """Return an iterable view which yields the string keys that would be represented by each :class:`.Row`. @@ -924,11 +922,6 @@ class Result(_WithKeys, ResultInternal): def __next__(self): return self._next_impl() - if py2k: - - def next(self): # noqa - return self._next_impl() - def partitions(self, size=None): """Iterate through sub-lists of rows of the size given. @@ -1325,11 +1318,6 @@ class ScalarResult(FilterResult): def __next__(self): return self._next_impl() - if py2k: - - def next(self): # noqa - return self._next_impl() - def first(self): """Fetch the first object or None if no object is present. @@ -1468,11 +1456,6 @@ class MappingResult(_WithKeys, FilterResult): def __next__(self): return self._next_impl() - if py2k: - - def next(self): # noqa - return self._next_impl() - def first(self): """Fetch the first object or None if no object is present. diff --git a/lib/sqlalchemy/engine/url.py b/lib/sqlalchemy/engine/url.py index 488f73952..be330eb6c 100644 --- a/lib/sqlalchemy/engine/url.py +++ b/lib/sqlalchemy/engine/url.py @@ -745,8 +745,6 @@ def _parse_rfc1738_args(name): query = {} for key, value in util.parse_qsl(components["query"]): - if util.py2k: - key = key.encode("ascii") if key in query: query[key] = util.to_list(query[key]) query[key].append(value) |