Changes between Initial Version and Version 1 of Ticket #16


Ignore:
Timestamp:
05/23/06 15:27:59 (8 years ago)
Author:
xi
Comment:

Fixed in [176].

When a mapping node cannot be correctly represented as a dictionary, PySyck is supposed to convert it to a list of pairs. So in this case, the expected value is

>>> syck.load('foo: bar\nfoo2: bar\nfoo: bar')
[('foo2', 'bar'), ('foo', 'bar'), ('foo', 'bar')]

I fixed the bug and now PySyck works as above.

But now I doubt if it's really a correct fix. The spec claims that a duplicate key in a mapping is an error. It's hard to check in all cases, but PyYAML tries to enforce it:

>>> yaml.load('foo: bar\nfoo2: bar\nfoo: bar')
Traceback (most recent call last):
  [...]
yaml.constructor.ConstructorError: while constructing a mapping
  in "<string>", line 1, column 1:
    foo: bar
    ^
found duplicate key
  in "<string>", line 3, column 1:
    foo: bar
    ^

So you shouldn't really use duplicate keys as they may cause an error in the next versions of PySyck.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16

    • Property Status changed from new to closed
    • Property Resolution changed from to fixed
  • Ticket #16 – Description

    initial v1  
    33I'm not sure if this is a defect in PySyck, or the underlying syck library. However, older versions of PySyck (<0.55) didn't suffer from this and merely overwrote the duplicate key with the new information. 
    44 
     5{{{ 
     6#!python 
    57>>> syck.load('foo: bar\nfoo2: bar') 
    68{'foo': 'bar', 'foo2': 'bar'} 
    79>>> syck.load('foo: bar\nfoo2: bar\nfoo: bar') 
    810[('foo', 'bar')] 
    9  
     11}}}