From 614672d365d6761353dbd11a8967a254d97035b7 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sat, 8 Jan 2011 15:07:45 +0000 Subject: [PATCH] Fixed #14888 -- Removing duplicated code in serialisers. Thanks to eric.fortin. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15163 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/serializers/base.py | 6 +++--- django/core/serializers/json.py | 3 --- django/core/serializers/pyyaml.py | 3 --- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py index 190636e670..cdcc7fa36a 100644 --- a/django/core/serializers/base.py +++ b/django/core/serializers/base.py @@ -31,9 +31,9 @@ class Serializer(object): """ self.options = options - self.stream = options.get("stream", StringIO()) - self.selected_fields = options.get("fields") - self.use_natural_keys = options.get("use_natural_keys", False) + self.stream = options.pop("stream", StringIO()) + self.selected_fields = options.pop("fields", None) + self.use_natural_keys = options.pop("use_natural_keys", False) self.start_serialization() for obj in queryset: diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py index b82c0a0ec7..b8119f54d4 100644 --- a/django/core/serializers/json.py +++ b/django/core/serializers/json.py @@ -18,9 +18,6 @@ class Serializer(PythonSerializer): internal_use_only = False def end_serialization(self): - self.options.pop('stream', None) - self.options.pop('fields', None) - self.options.pop('use_natural_keys', None) simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options) def getvalue(self): diff --git a/django/core/serializers/pyyaml.py b/django/core/serializers/pyyaml.py index 2ca68fe442..c443b63bc9 100644 --- a/django/core/serializers/pyyaml.py +++ b/django/core/serializers/pyyaml.py @@ -38,9 +38,6 @@ class Serializer(PythonSerializer): super(Serializer, self).handle_field(obj, field) def end_serialization(self): - self.options.pop('stream', None) - self.options.pop('fields', None) - self.options.pop('use_natural_keys', None) yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options) def getvalue(self):