diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-06-14 10:23:42 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:02 +0000 |
commit | 88abfbd8a29c5056eb0f089463cc28813bb172ad (patch) | |
tree | ef42bf10c430123f71a510afd889e0d3a8db8f1f /src/buildstream/_yaml.pyx | |
parent | 50335363cd49e7945567609cf8b1273576b27667 (diff) | |
download | buildstream-88abfbd8a29c5056eb0f089463cc28813bb172ad.tar.gz |
_yaml: Never create base 'Node' directly
We shouldn't have to create normal nodes ever. Let's ensure we don't
Diffstat (limited to 'src/buildstream/_yaml.pyx')
-rw-r--r-- | src/buildstream/_yaml.pyx | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx index e69ff8ee9..6a0080b37 100644 --- a/src/buildstream/_yaml.pyx +++ b/src/buildstream/_yaml.pyx @@ -521,13 +521,16 @@ cdef class Representer: cdef Node _create_node(object value, int file_index, int line, int column): - if type(value) in [bool, str, type(None), int]: + cdef type_value = type(value) + + if type_value in [bool, str, type(None), int]: return ScalarNode(value, file_index, line, column) - elif type(value) is dict: + elif type_value is dict: return MappingNode(value, file_index, line, column) - elif type(value) is list: + elif type_value is list: return SequenceNode(value, file_index, line, column) - return Node(value, file_index, line, column) + raise ValueError( + "Node values can only be 'list', 'dict', 'bool', 'str', 'int' or None. Not {}".format(type_value)) # Loads a dictionary from some YAML |