diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-01-03 21:43:02 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-01-03 21:43:02 +0100 |
commit | 80bd6e27946ed5b56b01687913369d6c895598cb (patch) | |
tree | 70f67cdc4c4e73a6e8ac7f4862d3d0b02a1ab99b /lib/extras.py | |
parent | a01700d478765e8dc6044336f21fe84808569a0d (diff) | |
parent | 627df159958330b54011e378427275b0494be013 (diff) | |
download | psycopg2-80bd6e27946ed5b56b01687913369d6c895598cb.tar.gz |
Merge branch 'python2' into python3
Conflicts:
NEWS-2.3
psycopg/connection_type.c
tests/test_connection.py
tests/types_basic.py
Diffstat (limited to 'lib/extras.py')
-rw-r--r-- | lib/extras.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/extras.py b/lib/extras.py index 56c0aad..69da526 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -769,7 +769,7 @@ class CompositeCaster(object): self.attnames = [ a[0] for a in attrs ] self.atttypes = [ a[1] for a in attrs ] - self.type = self._create_type(name, self.attnames) + self._create_type(name, self.attnames) self.typecaster = _ext.new_type((oid,), name, self.parse) def parse(self, s, curs): @@ -784,7 +784,7 @@ class CompositeCaster(object): attrs = [ curs.cast(oid, token) for oid, token in zip(self.atttypes, tokens) ] - return self.type(*attrs) + return self._ctor(*attrs) _re_tokenize = regex.compile(r""" \(? ([,\)]) # an empty token, representing NULL @@ -813,9 +813,11 @@ class CompositeCaster(object): try: from collections import namedtuple except ImportError: - return tuple + self.type = tuple + self._ctor = lambda *args: tuple(args) else: - return namedtuple(name, attnames) + self.type = namedtuple(name, attnames) + self._ctor = self.type @classmethod def _from_db(self, name, conn_or_curs): |