Skip to content

Commit

Permalink
Devicetree: edtlib: fix possible TypeError in Binding.__repr__()
Browse files Browse the repository at this point in the history
Calling Binding.__repr__() when the attribute Binding.path is None
would raise TypeError: expected str, bytes or os.PathLike object,
not  NoneType.

Known bindings that may not have a path (Binding.path is None)
include bindings for properties such as 'compatible', 'reg', 'status'.

Signed-off-by: Chris Duf <[email protected]>

Co-authored-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
2 people authored and mbolivar-nordic committed Oct 13, 2022
1 parent 0dc9f57 commit e067be5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/dts/python-devicetree/src/devicetree/edtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,8 @@ def __repr__(self):
compat = f" for compatible '{self.compatible}'"
else:
compat = ""
return f"<Binding {os.path.basename(self.path)}" + compat + ">"
basename = os.path.basename(self.path or "")
return f"<Binding {basename}" + compat + ">"

@property
def description(self):
Expand Down

0 comments on commit e067be5

Please sign in to comment.