Ticket #287 (new defect)

Opened 13 months ago

Last modified 3 days 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:


If YAML-Input is:

# ------------
    a: aa
    b: bb
# ------------
    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\", line 94, in safe_load

return load(stream, SafeLoader?)

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

return loader.get_single_data()

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

node = self.get_single_node()

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

document = self.compose_document()

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


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

self.current_event = self.state()

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

token = self.peek_token()

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


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

return self.fetch_value()

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


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!


Change History

comment:1 Changed 3 days ago by maskodok <galihadiputro87@…>

The only thing more I could hope for is documentation of all these features (other than reading through the code).  Cipto Junaedy Is this in process? Can I help? About  Unit Link Terbaik di Indonesia Commonwealth Life Investra Link


Add a comment

Modify Ticket

Change Properties
<Author field>
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'

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

Note: See TracTickets for help on using tickets.