Drop the Python 2 style interface from DictRow

Now standardizes on the Python 3 interface for all uses. Makes behavior
of DictRow between Pythons more consistent and predictable.
This commit is contained in:
Jon Dufresne 2017-12-11 19:09:18 -08:00
parent 3a6a8e96fb
commit f35465231f

View File

@ -176,16 +176,14 @@ class DictRow(list):
super(DictRow, self).__setitem__(x, v)
def items(self):
return list(self.iteritems())
for n, v in self._index.iteritems():
yield n, super(DictRow, self).__getitem__(v)
def keys(self):
return self._index.keys()
def values(self):
return tuple(self[:])
def has_key(self, x):
return x in self._index
return super(DictRow, self).__iter__()
def get(self, x, default=None):
try:
@ -193,16 +191,6 @@ class DictRow(list):
except:
return default
def iteritems(self):
for n, v in self._index.iteritems():
yield n, super(DictRow, self).__getitem__(v)
def iterkeys(self):
return self._index.iterkeys()
def itervalues(self):
return super(DictRow, self).__iter__()
def copy(self):
return dict(self.iteritems())
@ -216,13 +204,6 @@ class DictRow(list):
self[:] = data[0]
self._index = data[1]
# drop the crusty Py2 methods
if _sys.version_info[0] > 2:
items = iteritems # noqa
keys = iterkeys # noqa
values = itervalues # noqa
del iteritems, iterkeys, itervalues, has_key
class RealDictConnection(_connection):
"""A connection that uses `RealDictCursor` automatically."""