diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2016-08-15 01:55:57 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2016-08-15 01:56:36 +0100 |
commit | 78649f8e905f04c3000abef23725d557a103abef (patch) | |
tree | 60afa4c1829f9a0068ae9ea34ef3374eb86fd0f8 /lib/extras.py | |
parent | 3b41c3a6f373af0100a399cea150a9420ecc4acb (diff) | |
download | psycopg2-78649f8e905f04c3000abef23725d557a103abef.tar.gz |
Dropped use of b() "macro" and 2to3 fixer
Just use the b"" strings syntax supported from python 2.6.
Diffstat (limited to 'lib/extras.py')
-rw-r--r-- | lib/extras.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/extras.py b/lib/extras.py index 6ae9851..7a3a925 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -40,7 +40,6 @@ from psycopg2 import extensions as _ext from psycopg2.extensions import cursor as _cursor from psycopg2.extensions import connection as _connection from psycopg2.extensions import adapt as _A, quote_ident -from psycopg2.extensions import b from psycopg2._psycopg import REPLICATION_PHYSICAL, REPLICATION_LOGICAL from psycopg2._psycopg import ReplicationConnection as _replicationConnection from psycopg2._psycopg import ReplicationCursor as _replicationCursor @@ -575,7 +574,7 @@ class UUID_adapter(object): return self def getquoted(self): - return b("'%s'::uuid" % self._uuid) + return ("'%s'::uuid" % self._uuid).encode('utf8') def __str__(self): return "'%s'::uuid" % self._uuid @@ -635,7 +634,7 @@ class Inet(object): obj = _A(self.addr) if hasattr(obj, 'prepare'): obj.prepare(self._conn) - return obj.getquoted() + b("::inet") + return obj.getquoted() + b"::inet" def __conform__(self, proto): if proto is _ext.ISQLQuote: @@ -742,7 +741,7 @@ class HstoreAdapter(object): def _getquoted_8(self): """Use the operators available in PG pre-9.0.""" if not self.wrapped: - return b("''::hstore") + return b"''::hstore" adapt = _ext.adapt rv = [] @@ -756,23 +755,23 @@ class HstoreAdapter(object): v.prepare(self.conn) v = v.getquoted() else: - v = b('NULL') + v = b'NULL' # XXX this b'ing is painfully inefficient! - rv.append(b("(") + k + b(" => ") + v + b(")")) + rv.append(b"(" + k + b" => " + v + b")") - return b("(") + b('||').join(rv) + b(")") + return b"(" + b'||'.join(rv) + b")" def _getquoted_9(self): """Use the hstore(text[], text[]) function.""" if not self.wrapped: - return b("''::hstore") + return b"''::hstore" k = _ext.adapt(self.wrapped.keys()) k.prepare(self.conn) v = _ext.adapt(self.wrapped.values()) v.prepare(self.conn) - return b("hstore(") + k.getquoted() + b(", ") + v.getquoted() + b(")") + return b"hstore(" + k.getquoted() + b", " + v.getquoted() + b")" getquoted = _getquoted_9 |