fix(manifest): correct px_mkfw shebang order and _merge_manifest logic

Move the shebang to line 1 so direct execution works on Linux; the vim
modeline was sitting above it and silently breaking ./Tools/px_mkfw.py.

Fix _merge_manifest to only merge dict values into dst["hardware"] when
the key is "hardware". The previous structure ran the isinstance check
unconditionally, so any dict-valued field in the fragment would have
been shoved into dst["hardware"] regardless of its key, and could
KeyError if a non-"hardware" dict arrived first. It only worked today
because "hardware" happened to be the only dict in the fragment.

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
Ramon Roche 2026-04-08 21:12:36 -07:00
parent 63f059fd47
commit eacfab99cc
No known key found for this signature in database
GPG Key ID: 275988FAE5821713

View File

@ -1,5 +1,5 @@
# vim: set noexpandtab tabstop=4 shiftwidth=4:
#!/usr/bin/env python3
# vim: set noexpandtab tabstop=4 shiftwidth=4:
############################################################################
#
# Copyright (C) 2012, 2013 PX4 Development Team. All rights reserved.
@ -72,10 +72,8 @@ def _merge_manifest(dst, src):
if not isinstance(src, dict):
return
for k, v in src.items():
if k == "hardware":
dst.setdefault("hardware", {})
if isinstance(v, dict):
dst["hardware"].update(v)
if k == "hardware" and isinstance(v, dict):
dst.setdefault("hardware", {}).update(v)
else:
dst[k] = v