Modify

Ticket #113 (new defect)

Opened 5 years ago

Last modified 5 years ago

Changeset 313 dumps reduntant '...' (end of document)

Reported by: py4fun@… Owned by: xi
Priority: normal Component: pyyaml
Severity: normal Keywords:
Cc:

Description

When dumping a simple document (when there is no possibility of ambiguous parsing)

print '"%s"' % yaml.dump("abc")

a redundant "end of document" is emitted:

"abc
...
"

Attachments

Change History

comment:1 Changed 5 years ago by anonymous

This might be halfway intentional, since the description of the commit is: Emit an explicit document end indicator when there is a possibility of ambiguous parsing.

I think that on the root level the caller should be responsible if he uses dumped string in ambiguous way, since he can always request explicit_end.

Removing these lines removes the problem:

if hints[-1:] == u'+': 
    self.open_ended = True

comment:2 Changed 5 years ago by anonymous

Sorry, this is the proper diff

  • lib/yaml/emitter.py

     
    10751075            end += 1 
    10761076 
    10771077    def write_plain(self, text, split=True): 
    1078         if self.root_context: 
    1079             self.open_ended = True 
    10801078        if not text: 
    10811079            return 
    10821080        if not self.whitespace: 

comment:3 Changed 5 years ago by py4fun@…

The issue is: the caller should be responsible for emitting of a redundant 'end of document'. The caller is aware of the context (PyYAML is not). It is not convenient to massage the source code to get rid of unexpected output which reduces readability.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from xi. Next status will be 'new'
The owner will be changed from xi to anonymous. Next status will be 'assigned'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.