Skip to content

mockobject: Fix UpdateProperties for ObjectPath and Signature values - #252

Merged
martinpitt merged 1 commit into
martinpitt:mainfrom
leierx:wrap-object-path
Dec 2, 2026
Merged

martinpitt merged 1 commit into
martinpitt:mainfrom
leierx:wrap-object-path

Conversation

@leierx

@leierx leierx commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

UpdateProperties with a dbus.ObjectPath, dbus.Signature or dbus.ByteArray value fails:

org.freedesktop.DBus.Python.AttributeError: 'dbus.ObjectPath' object has no attribute 'conjugate'

_wrap_in_dbus_variant calls value.conjugate(), which only the numeric types have (same bug as #239 for Struct/Dict). type(value)(value, variant_level=1) works for every type in dbus_types except UnixFd, which was already broken and stays so.

_wrap_in_dbus_variant itself looks redundant since c9567f3: EmitSignal runs _convert_args("sa{sv}as", ...), which wraps a{sv} values in variants via Message.append (as bluez5.py already relies on). Passing properties straight to EmitSignal and dropping _wrap_in_dbus_variant also makes UnixFd and plain Python types (int, bool, list, …) work from templates. Happy to switch to that if preferred.

Test: test_properties updates an o and a g property; fails before, passes after.

UpdateProperties() with one of these values failed with "AttributeError:
'dbus.ObjectPath' object has no attribute 'conjugate'", as only the
numeric types have conjugate(). Their constructors all take an instance
of their own type, so pass the value through as is.

Signed-off-by: Lars Smith Eier <larssmitheier@protonmail.com>

@martinpitt martinpitt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Also for the _wrap_in_dbus_variant hint -- I'd be happy to lose this if possible, I didn't look into the details yet though. Do you want to send another PR for that, or should I look into that myself?

@martinpitt
martinpitt merged commit 7b8065d into martinpitt:main Dec 2, 2026
21 checks passed
@martinpitt

Copy link
Copy Markdown
Owner

@leierx actually, this sparked my interest now, I'll do a branch myself. After that I'll do a new release so you can use your two recent fixes. Cheers!

@martinpitt

Copy link
Copy Markdown
Owner

@leierx I fixed that in #254, that indeed spotted some more problems.

@leierx

leierx commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Cool! 🚀

@martinpitt

Copy link
Copy Markdown
Owner

@leierx : https://github.com/martinpitt/python-dbusmock/releases/tag/0.38.2 . I uploaded that to Debian unstable and Fedora 44/45/rawhide.

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.

2 participants