Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84e03f3

Browse files
committed
Undoing changes made for PYTHON-893. The underlying CPython bug is no longer
present in supported Python versions so it doesn't make sense to keep this around.
1 parent eee7523 commit 84e03f3

2 files changed

Lines changed: 0 additions & 110 deletions

File tree

cassandra/query.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -85,40 +85,6 @@ def tuple_factory(colnames, rows):
8585
"""
8686
return rows
8787

88-
class PseudoNamedTupleRow(object):
89-
"""
90-
Helper class for pseudo_named_tuple_factory. These objects provide an
91-
__iter__ interface, as well as index- and attribute-based access to values,
92-
but otherwise do not attempt to implement the full namedtuple or iterable
93-
interface.
94-
"""
95-
def __init__(self, ordered_dict):
96-
self._dict = ordered_dict
97-
self._tuple = tuple(ordered_dict.values())
98-
99-
def __getattr__(self, name):
100-
return self._dict[name]
101-
102-
def __getitem__(self, idx):
103-
return self._tuple[idx]
104-
105-
def __iter__(self):
106-
return iter(self._tuple)
107-
108-
def __repr__(self):
109-
return '{t}({od})'.format(t=self.__class__.__name__,
110-
od=self._dict)
111-
112-
113-
def pseudo_namedtuple_factory(colnames, rows):
114-
"""
115-
Returns each row as a :class:`.PseudoNamedTupleRow`. This is the fallback
116-
factory for cases where :meth:`.named_tuple_factory` fails to create rows.
117-
"""
118-
return [PseudoNamedTupleRow(od)
119-
for od in ordered_dict_factory(colnames, rows)]
120-
121-
12288
def named_tuple_factory(colnames, rows):
12389
"""
12490
Returns each row as a `namedtuple <https://docs.python.org/2/library/collections.html#collections.namedtuple>`_.
@@ -151,20 +117,6 @@ def named_tuple_factory(colnames, rows):
151117
clean_column_names = map(_clean_column_name, colnames)
152118
try:
153119
Row = namedtuple('Row', clean_column_names)
154-
except SyntaxError:
155-
warnings.warn(
156-
"Failed creating namedtuple for a result because there were too "
157-
"many columns. This is due to a Python limitation that affects "
158-
"namedtuple in Python 3.0-3.6 (see issue18896). The row will be "
159-
"created with {substitute_factory_name}, which lacks some namedtuple "
160-
"features and is slower. To avoid slower performance accessing "
161-
"values on row objects, Upgrade to Python 3.7, or use a different "
162-
"row factory. (column names: {colnames})".format(
163-
substitute_factory_name=pseudo_namedtuple_factory.__name__,
164-
colnames=colnames
165-
)
166-
)
167-
return pseudo_namedtuple_factory(colnames, rows)
168120
except Exception:
169121
clean_column_names = list(map(_clean_column_name, colnames)) # create list because py3 map object will be consumed by first attempt
170122
log.warning("Failed creating named tuple for results with column names %s (cleaned: %s) "

tests/unit/test_row_factories.py

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)