summaryrefslogtreecommitdiff
path: root/lib/extras.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2017-12-11 19:09:18 -0800
committerJon Dufresne <jon.dufresne@gmail.com>2017-12-11 20:02:16 -0800
commitf35465231f76039fae8677d48beacbdd2479095a (patch)
treea30826b22d392ca5b1d7081f3e0d2d75625921ac /lib/extras.py
parent3a6a8e96fbcad8e11843b1f3d04d1e0cb9ff4699 (diff)
downloadpsycopg2-f35465231f76039fae8677d48beacbdd2479095a.tar.gz
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.
Diffstat (limited to 'lib/extras.py')
-rw-r--r--lib/extras.py25
1 files changed, 3 insertions, 22 deletions
diff --git a/lib/extras.py b/lib/extras.py
index 85d94b3..64467a8 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -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."""