From 54f21c051489999dc8eacde711aea6b6381bcfbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Fri, 6 Apr 2018 09:19:03 +0200 Subject: [PATCH] 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. --- yamllint/parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yamllint/parser.py b/yamllint/parser.py index 335fa08..ae1ed5f 100644 --- a/yamllint/parser.py +++ b/yamllint/parser.py @@ -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)