yaml / pyyaml

Canonical source repository for PyYAML
MIT License
2.47k stars 507 forks source link

Yaml with a key called "on" parsed as True #744

Closed Puneeth-n closed 10 months ago

Puneeth-n commented 10 months ago

Hi, I am rather facing a weird issue with pyyaml library where a yaml string is not being parsed properly. the on key is parsed as boolean True. Any idea what is happening?

PyYAML==6.0 also tried the latest 5.x release

>>> import yaml
>>> yaml.full_load('on: {}')
{True: {}}
nitzmahone commented 10 months ago

Duplicate of many issues, eg, https://github.com/yaml/pyyaml/issues/613 - by design until PyYAML properly supports YAML 1.2 behavior.

nitzmahone commented 10 months ago

(see also https://github.com/yaml/pyyaml/issues/376#issuecomment-576821252 for a workaround)

Puneeth-n commented 10 months ago

Thanks for the info. I changed the loader to baseloader and it did the trick.

semenishchev commented 8 months ago

on = true off = false