Modify

Ticket #219 (reopened defect)

Opened 2 years ago

Last modified 2 years ago

A tab inside a scalar is not accepted

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

Description

I got the exception when a tab character (\t) is located inside a scalar:

import yaml

yaml.load("36L\tDIESEL")

This is the output of the latest source:

  File "C:\projects\py-workspace\pyyaml-trunk\lib\yaml\parser.py", line 143, in parse_implicit_document_start
    StreamEndToken):
  File "C:\projects\py-workspace\pyyaml-trunk\lib\yaml\scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "C:\projects\py-workspace\pyyaml-trunk\lib\yaml\scanner.py", line 257, in fetch_more_tokens
    % ch.encode('utf-8'), self.get_mark())
yaml.scanner.ScannerError: while scanning for the next token
found character '\t' that cannot start any token
  in "<string>", line 1, column 4:
    36L	DIESEL
       ^

When the tab character is replaced with a space, the parser works properly.

This issue was originally reported for SnakeYAML:  http://code.google.com/p/snakeyaml/issues/detail?id=136

Attachments

pyyaml-ticket-219.patch Download (1.1 KB) - added by py4fun@… 2 years ago.
Fix issue 219

Change History

comment:1 Changed 2 years ago by py4fun@…

I found the answer in scanner.py

def scan_plain_spaces(self, indent, start_mark):
    # See the specification for details.
    # The specification is really confusing about tabs in plain scalars.
    # We just forbid them completely. Do not use tabs in YAML!

comment:2 Changed 2 years ago by anonymous

  • Status changed from new to closed
  • Resolution set to wontfix

comment:3 Changed 2 years ago by anonymous

  • Status changed from closed to reopened
  • Resolution wontfix deleted

I think PyYAML must allow tabs in plain scalar. I attach the patch with solution for Python 2.x

Changed 2 years ago by py4fun@…

Fix issue 219

View

Add a comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.