summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2017-11-26 13:41:22 -0800
committerJon Dufresne <jon.dufresne@gmail.com>2017-11-26 13:55:30 -0800
commit05c28cce78aa223e632635af813cbbaed4c82169 (patch)
treef56ef8b70110ea7eb471e3f07d464f2f3ec37333 /lib
parent858bc3d42a4dfc65f6ec21e7ad28959f8255ab28 (diff)
downloadpsycopg2-05c28cce78aa223e632635af813cbbaed4c82169.tar.gz
Remove workarounds for namedtuple on Python <= 2.5
namedtuple is available on all Python versions supported by psycopg2. It was first introduced in Python 2.6. Can remove all workarounds and special documentation.
Diffstat (limited to 'lib')
-rw-r--r--lib/extras.py21
1 files changed, 5 insertions, 16 deletions
diff --git a/lib/extras.py b/lib/extras.py
index 8abb14f..bdd61f7 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -29,6 +29,7 @@ import os as _os
import sys as _sys
import time as _time
import re as _re
+from collections import namedtuple
try:
import logging as _logging
@@ -361,14 +362,8 @@ class NamedTupleCursor(_cursor):
except StopIteration:
return
- try:
- from collections import namedtuple
- except ImportError as _exc:
- def _make_nt(self):
- raise self._exc
- else:
- def _make_nt(self, namedtuple=namedtuple):
- return namedtuple("Record", [d[0] for d in self.description or ()])
+ def _make_nt(self):
+ return namedtuple("Record", [d[0] for d in self.description or ()])
class LoggingConnection(_connection):
@@ -1055,14 +1050,8 @@ class CompositeCaster(object):
return rv
def _create_type(self, name, attnames):
- try:
- from collections import namedtuple
- except ImportError:
- self.type = tuple
- self._ctor = self.type
- else:
- self.type = namedtuple(name, attnames)
- self._ctor = self.type._make
+ self.type = namedtuple(name, attnames)
+ self._ctor = self.type._make
@classmethod
def _from_db(self, name, conn_or_curs):