mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
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:
parent
3a6a8e96fb
commit
f35465231f
|
@ -176,16 +176,14 @@ class DictRow(list):
|
||||||
super(DictRow, self).__setitem__(x, v)
|
super(DictRow, self).__setitem__(x, v)
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
return list(self.iteritems())
|
for n, v in self._index.iteritems():
|
||||||
|
yield n, super(DictRow, self).__getitem__(v)
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
return self._index.keys()
|
return self._index.keys()
|
||||||
|
|
||||||
def values(self):
|
def values(self):
|
||||||
return tuple(self[:])
|
return super(DictRow, self).__iter__()
|
||||||
|
|
||||||
def has_key(self, x):
|
|
||||||
return x in self._index
|
|
||||||
|
|
||||||
def get(self, x, default=None):
|
def get(self, x, default=None):
|
||||||
try:
|
try:
|
||||||
|
@ -193,16 +191,6 @@ class DictRow(list):
|
||||||
except:
|
except:
|
||||||
return default
|
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):
|
def copy(self):
|
||||||
return dict(self.iteritems())
|
return dict(self.iteritems())
|
||||||
|
|
||||||
|
@ -216,13 +204,6 @@ class DictRow(list):
|
||||||
self[:] = data[0]
|
self[:] = data[0]
|
||||||
self._index = data[1]
|
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):
|
class RealDictConnection(_connection):
|
||||||
"""A connection that uses `RealDictCursor` automatically."""
|
"""A connection that uses `RealDictCursor` automatically."""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user