From a2ec1e6b2d05a1de86a6d02d1e035250b9fefa77 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Tue, 14 Nov 2017 00:12:46 +0500 Subject: [PATCH] Used BaseSimpleSerializer for serializing str and bytes in migrations. Follow up to c716fe87821df00f9f03ecc761c914d1682591a2. --- django/db/migrations/serializer.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/django/db/migrations/serializer.py b/django/db/migrations/serializer.py index 4df3776e54..d49df642cb 100644 --- a/django/db/migrations/serializer.py +++ b/django/db/migrations/serializer.py @@ -46,11 +46,6 @@ class BaseSimpleSerializer(BaseSerializer): return repr(self.value), set() -class ByteTypeSerializer(BaseSerializer): - def serialize(self): - return repr(self.value), set() - - class DatetimeSerializer(BaseSerializer): def serialize(self): if self.value.tzinfo is not None and self.value.tzinfo != utc: @@ -254,11 +249,6 @@ class SettingsReferenceSerializer(BaseSerializer): return "settings.%s" % self.value.setting_name, {"from django.conf import settings"} -class TextTypeSerializer(BaseSerializer): - def serialize(self): - return repr(self.value), set() - - class TimedeltaSerializer(BaseSerializer): def serialize(self): return repr(self.value), {"import datetime"} @@ -346,12 +336,8 @@ def serializer_factory(value): return SettingsReferenceSerializer(value) if isinstance(value, float): return FloatSerializer(value) - if isinstance(value, (bool, int, type(None))): + if isinstance(value, (bool, int, type(None), bytes, str)): return BaseSimpleSerializer(value) - if isinstance(value, bytes): - return ByteTypeSerializer(value) - if isinstance(value, str): - return TextTypeSerializer(value) if isinstance(value, decimal.Decimal): return DecimalSerializer(value) if isinstance(value, functools.partial):