Custom Query (121 matches)
Results (16 - 18 of 121)
| Ticket | Resolution | Summary | Owner | Reporter |
|---|---|---|---|---|
| #21 | duplicate | yaml emitter bug | xi | rwb123@… |
| Description |
The following code produces bad yaml output, which subsequently dies in the yaml.load(). This is with pyyaml 3.0.3 on python 2.4.1. import yaml e = {"texas: '": 92.5} yammy = yaml.dump(e) print yammy e2 = yaml.load(yammy) print e2 The yaml output is: $ python yamlbug2.py
{'texas: '': 92.5}
Traceback (most recent call last):
File "yamlbug2.py", line 10, in ?
e2 = yaml.load(yammy)
File "/home/blahblah/dl/yaml/PyYAML-3.03/lib/yaml/__init__.py", line 61, in load
return loader.get_data()
... etc.
|
|||
| #22 | fixed | Aliases break if there are temporary objects | xi | tim.hochberg@… |
| Description |
If an object being passed to represet_data has a shorter lifespan than the representer, the results are unpredictable, but generally bad. In my case, I'm trying to represent a custom omap class. I register a representer like so: def omap_representer(dumper, data):
items = [[x, y] for (x, y) in data.iteritems()]
return dumper.represent_sequence(u'!omap', items)
yaml.add_representer(omap, omap_representer)
If I then dump something that contains multiple omaps, such as [one_omap,another_omap], the representer get's confused because it sees distinct objects that have the same id. Here's an actual example: >>> a # Note that these are omaps not dictionaries, despite appearances.
[{1: 2, 2: 4}, {1: 99, 2: 88}]
>>> print yaml.dump(a)
- !omap
- &id001 [1, 2]
- &id002 [2, 4]
- !omap
- *id001
- *id002
Two approaches come to mind to fix this.
-tim |
|||
| #23 | fixed | Dictionary output not sorted. | xi | tim.hochberg@… |
| Description |
It is convenient to have YAML's output be consistent across runs. Some representers in PyYaml? do this already, but the dictionaries do not. I implemented a quick fix by replacing represent_dict with: def represent_dict(self, data):
items = data.items()
items.sort()
return self.represent_mapping(u'tag:yaml.org,2002:map', items)
It might also be convenient to have custom sort orders as PyYaml? legacy does, but that's a bigger change. |
|||
