Skip to content

Commit 0948eef

Browse files
authored
Do not read build string without first checking XNCP feature bitmap (#660)
* Do not read build string without first checking XNCP feature bitmap * Fix unit test
1 parent b7f3ef9 commit 0948eef

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

bellows/ezsp/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,11 @@ async def get_board_info(
362362
patch, ver_info_bytes = t.uint8_t.deserialize(ver_info_bytes)
363363
special, ver_info_bytes = t.uint8_t.deserialize(ver_info_bytes)
364364
version = f"{major}.{minor}.{patch}.{special} build {build}"
365+
build_string = None
365366

366-
try:
367-
build_string = await self.xncp_get_build_string()
368-
except InvalidCommandError:
369-
build_string = None
367+
if FirmwareFeatures.BUILD_STRING in self._xncp_features:
368+
with contextlib.suppress(InvalidCommandError):
369+
build_string = await self.xncp_get_build_string()
370370

371371
if build_string:
372372
version = f"{version} ({build_string})"

tests/test_ezsp.py

+3
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ async def replacement(command_name, tokenId=None, valueId=None):
388388

389389
return replacement
390390

391+
if not isinstance(xncp_build_string, InvalidCommandError):
392+
ezsp_f._xncp_features |= xncp.FirmwareFeatures.BUILD_STRING
393+
391394
with patch.object(
392395
ezsp_f,
393396
"_command",

0 commit comments

Comments
 (0)