Ticket #12914: pyyaml.patch
File pyyaml.patch, 971 bytes (added by , 15 years ago) |
---|
-
pyyaml.
old new 12 12 from django.core.serializers.python import Serializer as PythonSerializer 13 13 from django.core.serializers.python import Deserializer as PythonDeserializer 14 14 15 class DjangoSafeDumper(yaml.SafeDumper): 15 # Use the C (faster) implementation if possible 16 try: 17 from yaml import CLoader as Loader 18 from yaml import CSafeDumper as SafeDumper 19 except ImportError: 20 from yaml import Loader, SafeDumper 21 22 class DjangoSafeDumper(SafeDumper): 16 23 def represent_decimal(self, data): 17 24 return self.represent_scalar('tag:yaml.org,2002:str', str(data)) 18 25 … … 54 61 stream = StringIO(stream_or_string) 55 62 else: 56 63 stream = stream_or_string 57 for obj in PythonDeserializer(yaml.load(stream ), **options):64 for obj in PythonDeserializer(yaml.load(stream, Loader=Loader), **options): 58 65 yield obj 59 66