Custom Query (121 matches)
Results (31 - 33 of 121)
| Ticket | Resolution | Summary | Owner | Reporter |
|---|---|---|---|---|
| #53 | fixed | Allow for immutable subclasses of YAMLObject | xi | toidinamai |
| Description |
YAMLObject are not directly instantiated so they don't need their own instance attribute (i.e. an own dict). Because of that they should define an empty slots and let subclasses decide whether they want arbitrary instance attributes or not: --- lib/yaml/__init__.py (revision 251)
+++ lib/yaml/__init__.py (working copy)
@@ -272,6 +272,9 @@
yaml_tag = None
yaml_flow_style = None
+ # no direct instantiation, so allow for immutable subclasses
+ __slots__ = ()
+
def from_yaml(cls, loader, node):
"""
Convert a representation node to a Python object.
The same is basically also true for YAMLObjectMetaclass but I doubt there is much use for this in practice. |
|||
| #54 | fixed | load() fails to load consecutive documents | xi | cems at lanl dot gov |
| Description |
Description: if a file contains multiple documents, yaml.load() fails to work after the first document is read. I have a text file called test.yml that looks like this: --- as: "333 775260" --- zz: "top" the following code works as expected: f = open("test.xml") x = yaml.load_all(f) [ i for i in x] that loads both documents. it does it lazily using a generator x. The following does NOT work as exepcted: f = open("test.xml") yaml.load(f) yaml.load(f) the first yaml.load(f) works and loads the first document. the second one fails. From the documentation I beleive yaml.load should consecutively load the next document upon each invocation on the stream. The error message upon failing to load varies depending upon what is in the second document. In the case shown here is the stack trace from ipython2.5 In [153]: f = open("test4.yml") In [154]: yaml.load(f) Out[154]: {'as': '333 775260'} In [155]: yaml.load(f) <type 'exceptions.AttributeError?'> Traceback (most recent call last) /Users/cems/Documents/Collaboration/brettin/poisson_estimates/ace_to_yaml/<ipython console> in <module>() /sw/lib/python2.5/site-packages/yaml/init.py in load(stream, Loader)
---> 66 return loader.get_data()
/sw/lib/python2.5/site-packages/yaml/constructor.py in get_data(self)
---> 38 return self.construct_document(self.get_node())
/sw/lib/python2.5/site-packages/yaml/composer.py in get_node(self)
---> 23 return self.compose_document()
/sw/lib/python2.5/site-packages/yaml/composer.py in compose_document(self)
---> 35 node = self.compose_node(None, None)
/sw/lib/python2.5/site-packages/yaml/composer.py in compose_node(self, parent, index)
---> 52 anchor = event.anchor
<type 'exceptions.AttributeError?'>: 'NoneType?' object has no attribute 'anchor' In [156]: |
|||
| #60 | fixed | Error loading timestamps | xi | miki@… |
| Description |
Try the following script: #!/usr/bin/env python
import syck
from datetime import datetime
for i in range(10000):
now = datetime.now()
dumped = syck.dump(now)
loaded = syck.load(dumped)
if now != loaded:
print "original:", now
print "result:", loaded
print "dump:", dumped
break
I get: original: 2007-09-17 11:04:08.091612 result: 2007-09-17 11:04:08.916120 dump: --- !timestamp 2007-09-17T11:04:08.091612 The YAML looks OK, so the parsing is wrong. |
|||
