Modify ↓
Ticket #66 (closed defect: worksforme)
ScannerError in fetch_more_tokens
| Reported by: | Takanao Endoh <djmchl@…> | Owned by: | xi |
|---|---|---|---|
| Priority: | normal | Component: | pyyaml |
| Severity: | normal | Keywords: | |
| Cc: |
Description
>>> import yaml
>>> yaml.load(" 'spam: %' ")
'spam: %'
>>> yaml.load(" spam: % ")
------------------------------------------------------------
Traceback (most recent call last):
...
File "/Volumes/data/pylib/src/yaml/scanner.py", line 257, in fetch_more_tokens
% ch.encode('utf-8'), self.get_mark())
ScannerError: while scanning for the next token
found character '%' that cannot start any token
in "<string>", line 1, column 8:
spam: %
^
Attachments
Change History
comment:2 Changed 6 years ago by xi
- Status changed from new to closed
- Resolution set to worksforme
The error message speaks for itself: you cannot start a plain scalar with the % symbol. You need to quote the whole string with "..." or '...'.
See http://yaml.org/spec/cvs/current.html#ns-plain-first-char%28c%29 and http://yaml.org/spec/cvs/current.html#c-indicator
Note: See
TracTickets for help on using
tickets.

Sorry, I missed.
>>> import yaml >>> yaml.load(" spam: '%' ") {'spam': '%'} >>> yaml.load(" spam: % ") ------------------------------------------------------------ Traceback (most recent call last): ... File "/Volumes/data/pylib/src/yaml/scanner.py", line 257, in fetch_more_tokens % ch.encode('utf-8'), self.get_mark()) ScannerError: while scanning for the next token found character '%' that cannot start any token in "<string>", line 1, column 8: spam: % ^