Code

Opened 6 years ago

Closed 6 years ago

#8607 closed (fixed)

yaml serialization to file fails

Reported by: antony_hatchkins Owned by: nobody
Component: Core (Serialization) Version: master
Severity: Keywords: yaml
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When serializing anything to yaml with stream=open('file','w') it fails with the following error:

XMLSerializer = serializers.get_serializer('yaml')
serializer = XMLSerializer()
serializer.serialize(Partner.objects.all(), stream=open('partners.yaml', 'w'))

Traceback (most recent call last):

File "./bin/serialization/serialize_partners.py", line 16, in <module>

serializer.serialize(Partner.objects.all(), stream=out)

File "/var/django/phones-lev/django/core/serializers/base.py", line 56, in serialize

return self.getvalue()

File "./django/core/serializers/pyyaml.py", line 43, in getvalue

return self.stream.getvalue()

AttributeError: 'file' object has no attribute 'getvalue'

Attachments (2)

pyyaml.py (1.9 KB) - added by antony_hatchkins <antony.hatchkins@…> 6 years ago.
django\core\serializers\pyyaml.py
yaml-serialization-to-file.diff (531 bytes) - added by antony_hatchkins <antony.hatchkins@…> 6 years ago.
svn diff vs django r8671 which fixes the issue

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by antony_hatchkins <antony.hatchkins@…>

django\core\serializers\pyyaml.py

Changed 6 years ago by antony_hatchkins <antony.hatchkins@…>

svn diff vs django r8671 which fixes the issue

comment:1 Changed 6 years ago by antony_hatchkins <antony.hatchkins@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.