Opened 14 years ago

Last modified 14 years ago

#15193 closed

string indices must be integers, not str during YAML deserialization — at Initial Version

Reported by: Jack Owned by: nobody
Component: Core (Other) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Traceback:
Problem installing fixture 'data\init.yaml': Traceback (most recent call last):

File "C:\Python26\lib\site-packages\django\core\management\commands\loaddata.p

y", line 169, in handle

for obj in objects:

File "C:\Python26\lib\site-packages\django\core\serializers\pyyaml.py", line 5

9, in Deserializer

for obj in PythonDeserializer(objs, options):

File "C:\Python26\lib\site-packages\django\core\serializers\python.py", line 8

4, in Deserializer

Model = _get_model(dmodel)

TypeError: string indices must be integers, not str

I made the following change to pyyaml.py and it fixed the problem:

def Deserializer(stream_or_string, **options):
    """
    Deserialize a stream or string of YAML data.
    """
    if isinstance(stream_or_string, basestring):
        stream = StringIO(stream_or_string)
    else:
        stream = stream_or_string
    for obj in PythonDeserializer('''[yaml.load(stream),]''', **options):
        yield obj

I'm running Windows XP SP3 with this version of pyyaml:

http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.6.exe

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top