Skip to content

mockobject: Drop _wrap_in_dbus_variant from UpdateProperties; Fix property values with UnixFd, containers, or nested variants - #254

Merged
martinpitt merged 3 commits into
mainfrom
drop-wrap-in-dbus-variant
Dec 2, 2026
Merged

martinpitt merged 3 commits into
mainfrom
drop-wrap-in-dbus-variant

Conversation

@martinpitt

Copy link
Copy Markdown
Owner

Thanks to Lars Smith Eier @leierx for pointing this out in #252!

Matching the serialized XML in `test_introspection_properties` was
already brittle and does not scale to checking more properties. Parse it
with ElementTree instead.
…riants

Storing a property value unwrapped it with `copy.copy()`, to get the
actual type instead of "v" in introspection. That failed for UnixFd
values with "cannot pickle 'dbus.UnixFd' object", flattened nested
variants (variant_level 2 or more) to their content, and was skipped for
Array and Dictionary values, so that these got introspected as `v`.

Only unwrap values with exactly one variant level, which is the one that
comes from the AddProperty() and UpdateProperties() D-Bus arguments. Do
that explicitly for each kind of type.
The `PropertiesChanged` signal of `UpdateProperties()` failed for UnixFd
values ("Argument is not int and does not implement fileno() method"),
flattened nested variants, and rejected plain Python types like int,
bool, or list ("could not wrap type"), which templates pass when calling
it directly.

Wrapping the values into variants is redundant: since commit c9567f3,
EmitSignal() converts its arguments with Message.append() according to
the "sa{sv}as" signature, which already wraps the a{sv} values. The
bluez5 template already relies on that. So send the stored values as
they are.

Thanks to Lars Smith Eier for pointing this out!
@martinpitt
martinpitt merged commit 8f4d073 into main Dec 2, 2026
28 checks passed
@martinpitt
martinpitt deleted the drop-wrap-in-dbus-variant branch December 2, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant