From: Geert J. <ge...@gm...> - 2010-06-01 16:45:36
|
Hi, i'm using version 3.09 of PyYAML. When parsing a document with unresolvable tags, the default behavior of PyYAML seems to be to raise an exception. However i believe the YAML spec allows for a "partial" representation to be returned instead, according to section 3.3.2 of the YAML 1.1 spec: """If a document contains unresolved tags, the YAML processor is unable to compose a complete representation graph. In such a case, the YAML processor may compose an partial representation, based on each node’s kind and allowing for non-specific tags.""" These partial representations are useful with documents that you get from other sources and for which do you not have constructors for all tags. Example: s = "!tag test" print yaml.load(s) raises an exception. It's possible to parse the document by using this hack: from yaml import Loader del Loader.yaml_constructors[None] Two questions... - Would it be possible to return partial representations by default in case of unresolvable tags? - If not, would it be possible to have an API to enable it (so that i don't need to mess around with PyYAML internals). Thanks, Geert |