Comment 76 for bug 893091

Revision history for this message
In , Barry Warsaw (barry) wrote :

On Dec 13, 2011, at 11:17 AM, <email address hidden> wrote:

>To be clear, here is the semantic change I don't like: consider this D-Bus
>match rule:
>
> "arg0='/'"
>
>and these messages:
>
> o = dbus.lowlevel.SignalMessage('/', 'a.b', 'c')
> o.append('/', signature='o') # 0'th argument is an object path
>
> s = dbus.lowlevel.SignalMessage('/', 'a.b', 'c')
> s.append('/', signature='s') # 0'th argument is a string
>
>In the D-Bus Specification, dbus-daemon, and dbus-python for Python 2, the
>match rule matches s, but not o. In dbus-python for Python 3, because you
>removed the UTF8String type-check, it will match both.

To be perfectly clear, is this the test that needs to pass?

-----match.py-----
from __future__ import print_function, unicode_literals

from dbus.lowlevel import SignalMessage
from dbus.connection import SignalMatch

o = SignalMessage('/', 'a.b', 'c')
s = SignalMessage('/', 'a.b', 'c')

o.append('/', signature='o')
s.append('/', signature='s')

class Foo(object):
    pass
def ignore(*args, **kws):
    pass

m = SignalMatch(Foo(), None, '/', None, None, ignore, arg0='/')

print(m, "matches 's' signature (should be True)?", m.maybe_handle_message(s))
print(m, "matches 'o' signature (should be False)?", m.maybe_handle_message(o))
-----match.py-----

$ python match.py
type='signal',path='/',arg0='/' matches 's' signature (should be True)? True
type='signal',path='/',arg0='/' matches 'o' signature (should be False)? False

If so, I've added essentially this test to test-standalone.py and fixed the
code so that it passes in Python 2.x and 3.x.

I think I've addressed all your previous comments so far. The github branch
is up-to-date.

https://github.com/warsaw/dbus-python3/tree/python3

Please re-review. The revisions should be small enough and incremental enough
(with just the last few actually adding Python 3 support) to make it not as
painful as last time. ;)

Thanks!