Ticket #12914: pyyaml.patch

File pyyaml.patch, 971 bytes (added by Beuc, 15 years ago)

same, as patch

  • pyyaml.

    old new  
    1212from django.core.serializers.python import Serializer as PythonSerializer
    1313from django.core.serializers.python import Deserializer as PythonDeserializer
    1414
    15 class DjangoSafeDumper(yaml.SafeDumper):
     15# Use the C (faster) implementation if possible
     16try:
     17    from yaml import CLoader as Loader
     18    from yaml import CSafeDumper as SafeDumper
     19except ImportError:
     20    from yaml import Loader, SafeDumper
     21
     22class DjangoSafeDumper(SafeDumper):
    1623    def represent_decimal(self, data):
    1724        return self.represent_scalar('tag:yaml.org,2002:str', str(data))
    1825
     
    5461        stream = StringIO(stream_or_string)
    5562    else:
    5663        stream = stream_or_string
    57     for obj in PythonDeserializer(yaml.load(stream), **options):
     64    for obj in PythonDeserializer(yaml.load(stream, Loader=Loader), **options):
    5865        yield obj
    5966
Back to Top