Skip to content

Commit e067be5

Browse files
dottspinagmarull
authored andcommitted
Devicetree: edtlib: fix possible TypeError in Binding.__repr__()
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]>
1 parent 0dc9f57 commit e067be5

File tree

1 file changed

+2
-1
lines changed
  • scripts/dts/python-devicetree/src/devicetree

1 file changed

+2
-1
lines changed

scripts/dts/python-devicetree/src/devicetree/edtlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,8 @@ def __repr__(self):
18241824
compat = f" for compatible '{self.compatible}'"
18251825
else:
18261826
compat = ""
1827-
return f"<Binding {os.path.basename(self.path)}" + compat + ">"
1827+
basename = os.path.basename(self.path or "")
1828+
return f"<Binding {basename}" + compat + ">"
18281829

18291830
@property
18301831
def description(self):

0 commit comments

Comments
 (0)