summaryrefslogtreecommitdiff
path: root/parser.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-08-15 21:45:20 +0200
committerAnthon van der Neut <anthon@mnt.org>2019-08-15 21:45:20 +0200
commit1c628953c71f2e2f0cd01d643ca239e23c2e15cc (patch)
tree5023362ff0ebc313833d5c84bc358eb6f6d58110 /parser.py
parent64185b909c7107f1bc11644aa60bd901f8ec1bdc (diff)
downloadruamel.yaml-1c628953c71f2e2f0cd01d643ca239e23c2e15cc.tar.gz
move YAML directive info to scanner for TAG parsing of 1.2 URI
1.2 URI can contain the "#" character, but parsing for nodes didn't necessarily make the 1.2 version available in time fixes issue #301 *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to 'parser.py')
-rw-r--r--parser.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/parser.py b/parser.py
index 566d13a..10deaa8 100644
--- a/parser.py
+++ b/parser.py
@@ -109,7 +109,6 @@ class Parser(object):
# type: () -> None
# Reset the state attributes (to clear self-references)
self.current_event = None
- self.yaml_version = None
self.tag_handles = {} # type: Dict[Any, Any]
self.states = [] # type: List[Any]
self.marks = [] # type: List[Any]
@@ -269,12 +268,12 @@ class Parser(object):
def process_directives(self):
# type: () -> Any
- self.yaml_version = None
+ yaml_version = None
self.tag_handles = {}
while self.scanner.check_token(DirectiveToken):
token = self.scanner.get_token()
if token.name == u'YAML':
- if self.yaml_version is not None:
+ if yaml_version is not None:
raise ParserError(
None, None, 'found duplicate YAML directive', token.start_mark
)
@@ -286,7 +285,7 @@ class Parser(object):
'found incompatible YAML document (version 1.* is ' 'required)',
token.start_mark,
)
- self.yaml_version = token.value
+ yaml_version = token.value
elif token.name == u'TAG':
handle, prefix = token.value
if handle in self.tag_handles:
@@ -295,11 +294,11 @@ class Parser(object):
)
self.tag_handles[handle] = prefix
if bool(self.tag_handles):
- value = self.yaml_version, self.tag_handles.copy() # type: Any
+ value = yaml_version, self.tag_handles.copy() # type: Any
else:
- value = self.yaml_version, None
+ value = yaml_version, None
if self.loader is not None and hasattr(self.loader, 'tags'):
- self.loader.version = self.yaml_version
+ self.loader.version = yaml_version
if self.loader.tags is None:
self.loader.tags = {}
for k in self.tag_handles: