diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-06-10 19:53:35 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-06-10 19:56:16 +0200 |
| commit | 1a10a06b9f510f796beb2ffef39c7885cba2ad67 (patch) | |
| tree | ef20f6065f6ebcdec782a46fac7c91a5b2f21033 | |
| parent | e9497a3803c2da2d099ad1ca403a98cdb0ee322f (diff) | |
Fixed #18457 -- Fixed encoding error in yaml deserializer
Thanks jpaugh64 for the report.
| -rw-r--r-- | django/core/serializers/pyyaml.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/core/serializers/pyyaml.py b/django/core/serializers/pyyaml.py index 5effda5b46..e490b8607d 100644 --- a/django/core/serializers/pyyaml.py +++ b/django/core/serializers/pyyaml.py @@ -12,6 +12,8 @@ from django.db import models 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): @@ -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: |
