Fix #866: Add constructor for tag:yaml.org,2002:value#867
Fix #866: Add constructor for tag:yaml.org,2002:value#867mehulanshumali wants to merge 1 commit intoyaml:mainfrom
Conversation
|
Any news on this one ? |
|
Thank you for providing a fix! Is there a time frame when we can expect this to be available? |
|
I'm confused why anyone is pushing back on this and saying that = should fail on parsing. = is not a special char in yaml. It definitely gives me that fuzzy special feeling about it, and it seems like maybe it might be special some day, but it's not as of yaml 1.2. I would love to see this fix approved and merged in, because the npm package yaml is the fastest growing yaml support package for JavaScript projects, and it would default to serialize { compare: '=' } as compare: = , not compare: '='. I also can't imagine how this fix could possibly be a breaking change. |
PyYAML implements YAML 1.1, and there it is special: https://yaml.org/type/value.html The spec only talks about it when it's a mapping key. It doesn't specifically say what the library should do when it's not a mapping key, but returning the simple string seems the best thing to do, that's right.
You mention the node yaml package. In case you are using YAML 1.2, then it would make sense to try https://pypi.org/project/yamlcore/ which does not treat |
Problem
PyYAML fails to parse YAML documents containing standalone
=characters with:This affects real-world use cases like Prometheus CRDs with enum values containing
=.Root Cause
The YAML resolver correctly identifies standalone
=as having the tagtag:yaml.org,2002:value, but no constructor was defined for this tag in the SafeConstructor class.Solution
tag:yaml.org,2002:valuetoconstruct_yaml_str=as string scalar (consistent with YAML 1.1 specification)lib/yaml/constructor.pyTesting
Files Changed
lib/yaml/constructor.py: Added constructor fortag:yaml.org,2002:valueBackwards Compatibility
✅ No breaking changes - only adds support for previously unsupported syntax
Fixes #866