diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2013-04-07 18:06:43 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2013-04-07 22:19:04 +0100 |
commit | 711c092a79394b2ff09f77744464a97601d9a82e (patch) | |
tree | b9645c9f22bca859a47210aaf275689f3edbfa8b /lib/extras.py | |
parent | 61d496b2edb6946597a2dd7cd4ee105de2ea5b2b (diff) | |
download | psycopg2-711c092a79394b2ff09f77744464a97601d9a82e.tar.gz |
The UUID adapter returns bytes instead of str in Python 3
Also added __conform__ method to the adapter.
Diffstat (limited to 'lib/extras.py')
-rw-r--r-- | lib/extras.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/extras.py b/lib/extras.py index 33dd83d..c726626 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -449,13 +449,15 @@ class UUID_adapter(object): def __init__(self, uuid): self._uuid = uuid - def prepare(self, conn): - pass + def __conform__(self, proto): + if proto is _ext.ISQLQuote: + return self def getquoted(self): - return "'"+str(self._uuid)+"'::uuid" + return b("'%s'::uuid" % self._uuid) - __str__ = getquoted + def __str__(self): + return "'%s'::uuid" % self._uuid def register_uuid(oids=None, conn_or_curs=None): """Create the UUID type and an uuid.UUID adapter. @@ -514,8 +516,8 @@ class Inet(object): obj.prepare(self._conn) return obj.getquoted() + b("::inet") - def __conform__(self, foo): - if foo is _ext.ISQLQuote: + def __conform__(self, proto): + if proto is _ext.ISQLQuote: return self def __str__(self): |