Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load list of string with ':' in it, get different result with BaseLoader and SafeLoader #371

Closed
beegerous opened this issue Jan 10, 2020 · 1 comment
Labels

Comments

@beegerous
Copy link

file content:

a: 1
b:
  - 10:0
  - 100:0

my code

import yaml

print(yaml.__version__)
c = yaml.safe_load(open("./in"))
print(c)
c = yaml.unsafe_load(open("./in"))
print(c)
c = yaml.full_load(open("./in"))
print(c)
c = yaml.load(open("./in"), Loader=yaml.BaseLoader)
print(c)

and get result:

5.3
{'a': 1, 'b': [600, 6000]}
{'a': 1, 'b': [600, 6000]}
{'a': 1, 'b': [600, 6000]}
{'a': '1', 'b': ['10:0', '100:0']}
@perlpunk
Copy link
Member

This works as expected.
The BaseLoader loads everything as a string: https://pyyaml.org/wiki/PyYAMLDocumentation
The other loaders implement the YAML 1.1 types, and the integer type includes sexagesimals (numbers with base 60), which are seperated by colons: https://yaml.org/type/int.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants