UnboundLocalError: local variable 'node' referenced before assignment in CLoader

Issue #46 new
Joshua Klein
created an issue

Hello,

While trying to parse a YAML document piece by piece, the following code worked with the pure python Loader class, but when used under the CLoader class, an UnboundLocalError was thrown up:

 50             next_event = loader.peek_event()
     51             if isinstance(next_event, MappingEndEvent):
---> 52                 next_data = loader.get_data()
     53                 yield next_data
     54             elif isinstance(next_event, SequenceEndEvent):

C:\Anaconda\lib\site-packages\yaml\constructor.pyc in get_data(self)
     31         # Construct and return the next document.
     32         if self.check_node():
---> 33             return self.construct_document(self.get_node())
     34 
     35     def get_single_data(self):

_yaml.pyx in _yaml.CParser.get_node (ext/_yaml.c:8189)()

_yaml.pyx in _yaml.CParser._compose_document (ext/_yaml.c:8581)()

_yaml.pyx in _yaml.CParser._compose_node (ext/_yaml.c:9336)()

UnboundLocalError: local variable 'node' referenced before assignment

This looks like a case where the if-elif cascade at _yaml.pyx line 771-777 doesn't have a final else clause. Is this working as intended?

Comments (0)

  1. Log in to comment