Modify

Ticket #287 (new defect)

Opened 13 months ago

Different behaviour for comment lines ending with "-" in YAML-Python2 and YAML-Python3

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

Description

If YAML-Input is:

# ------------
'11':
    a: aa
    b: bb
# ------------
'22':
    c: cc
    d: dd
# ------------

In Python-2 (2.7.3 with PyYAML-3.10.win32-py2.7) I get the result:

{'11': {'a': 'aa', 'b': 'bb'}, '22': {'c': 'cc', 'd': 'dd'}}

In Python-3 (3.2.1 with PyYAML-3.10.win32-py3.2) the result is:

Traceback (most recent call last):

File "<stdin>", line 1, in <module> File "C:\Sysware\Python3-32\lib\site-packages\yaml\init.py", line 94, in safe_load

return load(stream, SafeLoader?)

File "C:\Sysware\Python3-32\lib\site-packages\yaml\init.py", line 72, in load

return loader.get_single_data()

File "C:\Sysware\Python3-32\lib\site-packages\yaml\constructor.py", line 35, in get_single_data

node = self.get_single_node()

File "C:\Sysware\Python3-32\lib\site-packages\yaml\composer.py", line 36, in get_single_node

document = self.compose_document()

File "C:\Sysware\Python3-32\lib\site-packages\yaml\composer.py", line 58, in compose_document

self.get_event()

File "C:\Sysware\Python3-32\lib\site-packages\yaml\parser.py", line 118, in get_event

self.current_event = self.state()

File "C:\Sysware\Python3-32\lib\site-packages\yaml\parser.py", line 193, in parse_document_end

token = self.peek_token()

File "C:\Sysware\Python3-32\lib\site-packages\yaml\scanner.py", line 128, in peek_token

self.fetch_more_tokens()

File "C:\Sysware\Python3-32\lib\site-packages\yaml\scanner.py", line 220, in fetch_more_tokens

return self.fetch_value()

File "C:\Sysware\Python3-32\lib\site-packages\yaml\scanner.py", line 580, in fetch_value

self.get_mark())

yaml.scanner.ScannerError?: mapping values are not allowed here

in "C:E\Python2\Test\!_Allg\YAML_Daten_Test.yaml", line 2, column 5

If I put another character than "-" at the end of the comment lines, then the Python3-YAML works well! Perhaps there is a new interpretation of the "-" in the Python3-YAML-Version (continuation sign?), but I've found nothing about that in the YAML documentation.

Greetings ... Norbert Hoyer

By the way ... YAML for Python is a great work - congratulations!

Attachments

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.