summaryrefslogtreecommitdiff
path: root/django/core/serializers/pyyaml.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-06-15 14:41:16 +0200
committerClaude Paroz <claude@2xlibre.net>2012-06-15 14:49:19 +0200
commit5bdd0d6b6a8d5cfa88077c6837a21041c7bfd562 (patch)
treeb8e6d51771ba21de44b30c4729655ee86887163d /django/core/serializers/pyyaml.py
parentfd6a9d35d9034436d2f8092717c5b210da6ff6ce (diff)
Favored text (StringIO) over binary content for deserialization
This is also more Python 3 compatible, as the json module in Python 3 is expecting text. Thanks Vinay Sajip for noticing it.
Diffstat (limited to 'django/core/serializers/pyyaml.py')
-rw-r--r--django/core/serializers/pyyaml.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/django/core/serializers/pyyaml.py b/django/core/serializers/pyyaml.py
index e490b8607d..b639ad2dae 100644
--- a/django/core/serializers/pyyaml.py
+++ b/django/core/serializers/pyyaml.py
@@ -6,7 +6,7 @@ Requires PyYaml (http://pyyaml.org/), but that's checked for in __init__.
import decimal
import yaml
-from io import BytesIO
+from io import StringIO
from django.db import models
from django.core.serializers.base import DeserializationError
@@ -51,9 +51,9 @@ def Deserializer(stream_or_string, **options):
Deserialize a stream or string of YAML data.
"""
if isinstance(stream_or_string, bytes):
- stream = BytesIO(stream_or_string)
- if isinstance(stream_or_string, unicode):
- stream = BytesIO(smart_str(stream_or_string))
+ stream_or_string = stream_or_string.decode('utf-8')
+ if isinstance(stream_or_string, basestring):
+ stream = StringIO(stream_or_string)
else:
stream = stream_or_string
try: