parser: Fix crash with latest PyYAML

There is a backwards-incompatible change in PyYAML that induces a crash
if `check_token()` is not called before `peek_token()`. See commit
a02d17a in PyYAML or https://github.com/yaml/pyyaml/pull/150.

Closes #105.
This commit is contained in:
Adrien Vergé 2018-04-06 09:19:03 +02:00
parent 36b4776778
commit 54f21c0514

View File

@ -125,7 +125,8 @@ def token_or_comment_generator(buffer):
curr = yaml_loader.get_token()
while curr is not None:
next = yaml_loader.get_token()
nextnext = yaml_loader.peek_token()
nextnext = (yaml_loader.peek_token()
if yaml_loader.check_token() else None)
yield Token(curr.start_mark.line + 1, curr, prev, next, nextnext)