Skip to content

Commit

Permalink
Fixed #18457 -- Fixed encoding error in yaml deserializer
Browse files Browse the repository at this point in the history
Thanks jpaugh64 for the report.
  • Loading branch information
claudep committed Jun 10, 2012
1 parent e9497a3 commit 1a10a06
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion django/core/serializers/pyyaml.py
Expand Up @@ -12,6 +12,8 @@
from django.core.serializers.base import DeserializationError
from django.core.serializers.python import Serializer as PythonSerializer
from django.core.serializers.python import Deserializer as PythonDeserializer
from django.utils.encoding import smart_str


class DjangoSafeDumper(yaml.SafeDumper):
def represent_decimal(self, data):
Expand Down Expand Up @@ -48,8 +50,10 @@ def Deserializer(stream_or_string, **options):
"""
Deserialize a stream or string of YAML data.
"""
if isinstance(stream_or_string, basestring):
if isinstance(stream_or_string, bytes):
stream = BytesIO(stream_or_string)
if isinstance(stream_or_string, unicode):
stream = BytesIO(smart_str(stream_or_string))
else:
stream = stream_or_string
try:
Expand Down

0 comments on commit 1a10a06

Please sign in to comment.