Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variant ('v') type does not handle {1: True, 2:False} #23

Open
socketpair opened this issue Nov 24, 2014 · 3 comments
Open

variant ('v') type does not handle {1: True, 2:False} #23

socketpair opened this issue Nov 24, 2014 · 3 comments

Comments

@socketpair
Copy link

At least, in python2 (where isinstance(True, int) is True) If I try to serialize {1: True, 2:False} as DBUS's variant, it is really serialized as {1: 1, 2:0}.

And also txdbus allows mix of types in such dicts., for example, {1:'s', 'd': True}

@neowulf
Copy link

neowulf commented Mar 7, 2016

+1

Is there another way to over come this?

@cocagne
Copy link
Owner

cocagne commented Mar 7, 2016

Looks like this may have been a simple oversight in the marshalling logic.
Try adding "elif isinstance(pobj, bool): return 'b'" to line 243 of
txdbus/marshal.py and see if that resolves the issue. Doing so didn't break
any of the unit tests but it's been several years since I've thought about
this code so most of the details have gone fuzzy. Let me know what happens.

As to the mixed types in dictionaries, that was partially intentional. It's
an efficiency condition where I can either check a single element or
iterate over all elements to ensure that all types match. I went back and
forth on it and figured that it's more of a programming bug that wasn't
worth a continual runtime penalty to constantly check. It's definitely
debatable though as to whether or not that's the best choice.

Tom

On Mon, Mar 7, 2016 at 1:49 AM, neowulf33 [email protected] wrote:

+1

Is there another way to over come this?


Reply to this email directly or view it on GitHub
#23 (comment).

@neowulf
Copy link

neowulf commented Mar 7, 2016

Hi Tom,

Thank you for the quick response. I was able to do the following to overcome this issue:

yield remote_obj.callRemote('SetProperty', 'prop_name', marshal.Boolean(1), interface='net.interface.name')

marshal.Boolean(1) correctly yielded variant:boolean:true

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

No branches or pull requests

3 participants