Ticket #240 (new defect)
Block and / or folded literal dumps fail on trailing space
| Reported by: | yarkot1@… | Owned by: | xi |
|---|---|---|---|
| Priority: | normal | Component: | pyyaml |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Goal: Yaml output of both block and folded styles, such as: folded_example: >
I have some text here and then some more here.
literal_style: |
I have some text here and some more here.
Approach: Searching, I found this http://stackoverflow.com/questions/6432605 approach, which seems to work reasonably well _except_ for a peculiar data situation ("the BUG").
PROBLEM: If the source python dict looks like this:
d = { 'x': literal_unicode('I have some text here\n and some more here.\n') } print(yaml.dump(d))
x: |
I have some text here
and some more here.
If the source has any trailing whitespace before the newlines (tab or spaces tested), then the output changes to this:
d = { 'x': literal_unicode('I have some text here\n and some more here.\t\n') } print(yaml.dump(d))
x: "I have some text here\n and some more here.\t\n"
Likewise for folded representation:
d = { 'x': folded_unicode('I have some text here\n and some more here.\t\n') } print(yaml.dump(d))
x: "I have some text here\n and some more here.\t\n"
d = { 'x': folded_unicode('I have some text here\n and some more here.\n') } print(yaml.dump(d))
x: >
I have some text here
and some more here.
OS/X Snow Leopard; Python Version 2.7.3 pyYaml '3.10'

Also, if the block has a '\t', the same thing happens.
Yarko