Opened 14 years ago

Closed 14 years ago

#15193 closed (invalid)

string indices must be integers, not str during YAML deserialization

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 (last modified by Russell Keith-Magee)

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(d["model"])
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 (2)

comment:1 by Jack, 14 years ago

Sorry, I realized that I can't use ''' inside code snippet, please disregard it around:
'''[yaml.load(stream),]'''

comment:2 by Russell Keith-Magee, 14 years ago

Description: modified (diff)
Resolution: invalid
Status: newclosed

Marking invalid -- report doesn't give any indication of *why* the proposed change is required, other than apparent abiility of the reporter to generate a stack trace.

In order for a bug report to be useful, you need to give us the ability to reproduce a problem. That means a complete set of instructions that would allow someone else to reproduce the problem.

If you care to provide such instructions, please repoen this ticket with those details.

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