Fixed -- Fixed SchemaEditor.quote_value() crash with bytes.
@@ -230,7 +230,14 @@ class DatabaseWrapper(BaseDatabaseWrapper):
@async_unsafe
def get_new_connection(self, conn_params):
- return Database.connect(**conn_params)
+ connection = Database.connect(**conn_params)
+ # bytes encoder in mysqlclient doesn't work and was added only to
+ # prevent KeyErrors in Django < 2.0. We can remove this workaround when
+ # mysqlclient 2.1 becomes the minimal mysqlclient supported by Django.
+ # See https://github.com/PyMySQL/mysqlclient/issues/489
+ if connection.encoders.get(bytes) is bytes:
+ connection.encoders.pop(bytes)
+ return connection
def init_connection_state(self):
assignments = []
