Skip to content

Commit 230c80e

Browse files
dottspinagmarull
authored andcommitted
Devicetree: edtlib: fix possible AttributeError in Property.description
Attempting to access the property Property.description when Property.spec.description is None would raise AttributeError: 'NoneType' object has no attribute 'strip'. Known properties that may not have a description (Property.spec.description is None): - 'compatible' for nodes such as / /soc /soc/timer@e000e010 /leds /pwmleds - 'reg' for nodes such as /soc/timer@e000e010 - 'status' for nodes such as /soc/timer@e000e010 - 'gpios' for nodes such as /leds/led_0 /buttons/button_0 - 'pwms' for nodes such as /pwmleds/pwm_led_0 This patch checks the PropertySpec.description attribute before calling strip(): will return None, and not raise AttributeError. Signed-off-by: Chris Duf <[email protected]> Co-authored-by: Gerard Marull-Paretas <[email protected]>
1 parent 2530ba5 commit 230c80e

File tree

1 file changed

+3
-3
lines changed
  • scripts/dts/python-devicetree/src/devicetree

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,8 +1610,8 @@ class Property:
16101610
Convenience for spec.name.
16111611
16121612
description:
1613-
Convenience for spec.name with leading and trailing whitespace
1614-
(including newlines) removed.
1613+
Convenience for spec.description with leading and trailing whitespace
1614+
(including newlines) removed. May be None.
16151615
16161616
type:
16171617
Convenience for spec.type.
@@ -1655,7 +1655,7 @@ def name(self):
16551655
@property
16561656
def description(self):
16571657
"See the class docstring"
1658-
return self.spec.description.strip()
1658+
return self.spec.description.strip() if self.spec.description else None
16591659

16601660
@property
16611661
def type(self):

0 commit comments

Comments
 (0)