mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 03:26:37 +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)
|
||||
|
||||
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."""
|
||||
|
|
Loading…
Reference in New Issue
Block a user