Skip to content

Strings with a number ending in eight or nine are dumped as integers #524

@albertca

Description

@albertca

Here's a small snippet to reproduce the problem:

import yaml

for x in range(0, 12):
    yaml.dump({'a': '%06s' % x})

And here the output:

"a: '000000'\n"
"a: '000001'\n"
"a: '000002'\n"
"a: '000003'\n"
"a: '000004'\n"
"a: '000005'\n"
"a: '000006'\n"
"a: '000007'\n"
'a: 000008\n'
'a: 000009\n'
"a: '000010'\n"
"a: '000011'\n"

For some reason numbers ending in 8 or 9 are dumped as integers, but they should be strings just like the rest of the numbers. Using larger numbers shows that all numbers ending in 8 or 9 are always dumped as integers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions