From 874908e3bba8538d1c108e1b38f9d9519c6e5416 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sun, 23 Sep 2012 20:32:17 +0200 Subject: [PATCH] [py3] Updated PostGIS adapter --- django/contrib/gis/db/backends/postgis/adapter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/django/contrib/gis/db/backends/postgis/adapter.py b/django/contrib/gis/db/backends/postgis/adapter.py index 863ee78acd..8bb514d760 100644 --- a/django/contrib/gis/db/backends/postgis/adapter.py +++ b/django/contrib/gis/db/backends/postgis/adapter.py @@ -1,6 +1,7 @@ """ This object provides quoting for GEOS geometries into PostgreSQL/PostGIS. """ +from __future__ import unicode_literals from psycopg2 import Binary from psycopg2.extensions import ISQLQuote @@ -10,7 +11,7 @@ class PostGISAdapter(object): "Initializes on the geometry." # Getting the WKB (in string form, to allow easy pickling of # the adaptor) and the SRID from the geometry. - self.ewkb = str(geom.ewkb) + self.ewkb = bytes(geom.ewkb) self.srid = geom.srid self._adapter = Binary(self.ewkb) @@ -39,7 +40,7 @@ class PostGISAdapter(object): def getquoted(self): "Returns a properly quoted string for use in PostgreSQL/PostGIS." # psycopg will figure out whether to use E'\\000' or '\000' - return 'ST_GeomFromEWKB(%s)' % self._adapter.getquoted() + return str('ST_GeomFromEWKB(%s)' % self._adapter.getquoted().decode()) def prepare_database_save(self, unused): return self