Skip to content

Commit 8a4e6fd

Browse files
samuel-gauthierrjarry
authored andcommitted
schema: check cdata_parsed before using it
Sometimes, cdata_parsed is None. Check it before using it, as we do in the other functions using cdata_parsed. It fixes this error: AttributeError: 'NoneType' object has no attribute 'range' Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com>
1 parent 6fd7764 commit 8a4e6fd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libyang/schema.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ def all_bits(self) -> Iterator[Bit]:
515515
NUM_TYPES = frozenset((INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64))
516516

517517
def range(self) -> Optional[str]:
518+
if not self.cdata_parsed:
519+
return None
518520
if (
519521
self.cdata.basetype in self.NUM_TYPES or self.cdata.basetype == self.DEC64
520522
) and self.cdata_parsed.range != ffi.NULL:

0 commit comments

Comments
 (0)