Browse files

Fixed #13161 - UNICODE registering changed

Previously, Django would register UNICODE extensions for psycopg2 at global scope, causing all other Python applications running under the same interpreter to be fed Unicode objects instead of expected strings. This would break those applications.
Now Django will register UNICODE only on per-cursor basic, so other applications will be unaffected.
  • Loading branch information...
piotrmaslanka committed Dec 16, 2012
1 parent 69597e5 commit 6595ee896a9e3bf9cc1a9bd34af0e13bd32d8a3b
Showing with 1 addition and 1 deletion.
  1. +1 −1 django/db/backends/postgresql_psycopg2/
@@ -29,7 +29,6 @@
DatabaseError = Database.DatabaseError
IntegrityError = Database.IntegrityError
psycopg2.extensions.register_adapter(SafeBytes, psycopg2.extensions.QuotedString)
psycopg2.extensions.register_adapter(SafeText, psycopg2.extensions.QuotedString)
@@ -211,6 +210,7 @@ def _cursor(self):
connection_created.send(sender=self.__class__, connection=self)
cursor = self.connection.cursor()
+ psycopg2.extensions.register_type(psycopg2.extensions.UNICODE, cursor)
cursor.tzinfo_factory = utc_tzinfo_factory if settings.USE_TZ else None
return CursorWrapper(cursor)

0 comments on commit 6595ee8

Please sign in to comment.