Merge lp:~xnox/bzr-dbus/pygi into lp:bzr-dbus

Proposed by Dimitri John Ledkov
Status: Merged
Approved by: Richard Wilbur
Approved revision: 53
Merged at revision: 53
Proposed branch: lp:~xnox/bzr-dbus/pygi
Merge into: lp:bzr-dbus
Diff against target: 251 lines (+31/-30)
2 files modified
activity.py (+6/-5)
tests/test_activity.py (+25/-25)
To merge this branch: bzr merge lp:~xnox/bzr-dbus/pygi
Reviewer Review Type Date Requested Status
Robert Bruce Park (community) Approve
Richard Wilbur Approve
Martin Pitt (community) Approve
Review via email: mp+137173@code.launchpad.net

Commit message

Remove PyGIDeprecationWarnings

Description of the change

Resolve Bug #1095884: "bzr showing PyGIDeprecationWarning for all actions." by moving from using deprecated interfaces of GObject to undeprecated interfaces of GLib.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

One left:
PyGIDeprecationWarning: Calling io_add_watch with a file object is deprecated; call it with a GLib.IOChannel object

Revision history for this message
Martin Pitt (pitti) wrote :

This looks good to me, thanks! Don't worry about the IOChannel warning; I think deprecating this one was a bit overzealous, supporting this mode is not all that expensive (unlike calling it with wrong arguments). I dropped the warning in

http://git.gnome.org/browse/pygobject/commit/?id=945263a8

review: Approve
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

Looks good to me. Thanks for fixing up the code rot by moving bzr-dbus to the blessed interfaces.
+1

review: Approve
Revision history for this message
Robert Bruce Park (robru) wrote :

Works for me, too!

review: Approve
Revision history for this message
Andrew Starr-Bochicchio (andrewsomething) wrote :

FYI, the fix isn't backwards compatible (not sure if it aims to be). It creates a number of test failures on Debian sid with python-gobject-2, though it might just be time to drop all the 'import glib as GLib' stuff. They also fail with the versions of python-gi in both sid and experimental.

======================================================================
ERROR: bzrlib.plugins.dbus.tests.test_activity.TestLanGateway.test_network_packets_trigger_handle_network_packet
----------------------------------------------------------------------
_StringException: Empty attachments:
  log

Traceback (most recent call last):
  File "/tmp/buildd/bzr-dbus-0.1~bzr53/tests/test_activity.py", line 516, in test_network_packets_trigger_handle_network_packet
    gateway.run(_port=0)
  File "/tmp/buildd/bzr-dbus-0.1~bzr53/activity.py", line 313, in run
    self.start(_port)
  File "/tmp/buildd/bzr-dbus-0.1~bzr53/activity.py", line 332, in start
    GLib.io_add_watch(self.sock, GLib.PRIORITY_HIGH, GLib.IO_IN, self.handle_network_packet)
TypeError: third argument not callable

======================================================================
ERROR: bzrlib.plugins.dbus.tests.test_activity.TestLanGateway.test_run_binds
----------------------------------------------------------------------
_StringException: Empty attachments:
  log

Traceback (most recent call last):
  File "/tmp/buildd/bzr-dbus-0.1~bzr53/tests/test_activity.py", line 493, in test_run_binds
    gateway.run(_port=0)
  File "/tmp/buildd/bzr-dbus-0.1~bzr53/activity.py", line 313, in run
    self.start(_port)
  File "/tmp/buildd/bzr-dbus-0.1~bzr53/activity.py", line 332, in start
    GLib.io_add_watch(self.sock, GLib.PRIORITY_HIGH, GLib.IO_IN, self.handle_network_packet)
TypeError: third argument not callable

======================================================================
ERROR: bzrlib.plugins.dbus.tests.test_activity.TestLanGateway.test_run_listens_for_revisions
----------------------------------------------------------------------
_StringException: Empty attachments:
  log

Traceback (most recent call last):
  File "/tmp/buildd/bzr-dbus-0.1~bzr53/tests/test_activity.py", line 543, in test_run_listens_for_revisions
    gateway.run(_port=0)
  File "/tmp/buildd/bzr-dbus-0.1~bzr53/activity.py", line 313, in run
    self.start(_port)
  File "/tmp/buildd/bzr-dbus-0.1~bzr53/activity.py", line 332, in start
    GLib.io_add_watch(self.sock, GLib.PRIORITY_HIGH, GLib.IO_IN, self.handle_network_packet)
TypeError: third argument not callable

----------------------------------------------------------------------
Ran 37 tests in 1.092s

FAILED (errors=3)

Revision history for this message
Robert Bruce Park (robru) wrote :

Andrew, can you try my branch briefly? I ran the testsuite and didn't get the errors you say.

I wrote this a little while ago and don't remember all the details, but I do vaguely remember going into a python2 interactive shell and trying "import glib as GLib" and then poking some of the methods interactively, and seeing that it was working.

https://code.launchpad.net/~robru/bzr-dbus/glib

(also, I think this branch is more complete, as it no longer imports gobject at all)

Thanks!

Revision history for this message
Andrew Starr-Bochicchio (andrewsomething) wrote :

Robert,

I was able to successfully run the test suite in a minimal Debian sid chroot using your branch with python-gi installed as well as with only python-gobject-2.

Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

On Sun, Jan 27, 2013 at 1:39 PM, Andrew Starr-Bochicchio
<email address hidden> wrote:
> FYI, the fix isn't backwards compatible (not sure if it aims to be). It creates a number of test
> failures on Debian sid with python-gobject-2, though it might just be time to drop all the
> 'import glib as GLib' stuff. They also fail with the versions of python-gi in both sid and experimental.

Andrew,

I must confess that I wasn't looking for backwards compatibility since
we were merging into trunk of bzr-dbus, but if we can have our cake
and eat it too...

So what version of bzr, python, etc. are you testing against?

I thought the original incompatibility this branch intended to fix was
a problem with GObject API deprecation but the test failures you see
complain about GLib usage. Is it due to an older version of GLib, or
possibly something else?

Richard

Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

On Sun, Jan 27, 2013 at 2:21 PM, Robert Bruce Park
<email address hidden> wrote:
[...]
> https://code.launchpad.net/~robru/bzr-dbus/glib
>
> (also, I think this branch is more complete, as it no longer imports gobject at all)
[...]

It sounds like this is a better solution than what was previously
merged. Is your branch ready to merge? If so, would you be willing
to propose a merge? I would be happy to approve it.

Sincerely,

Richard

Revision history for this message
Robert Bruce Park (robru) wrote :

On Thu, Mar 21, 2013 at 05:55:22AM -0000, Richard Wilbur wrote:
> It sounds like this is a better solution than what was previously
> merged. Is your branch ready to merge? If so, would you be willing
> to propose a merge? I would be happy to approve it.

Ah, I figured the issue was moot at this point. But, since you've
shown an interest, I've rebased my branch on master and submitted a
new mp. Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'activity.py'
--- activity.py 2012-01-31 20:07:01 +0000
+++ activity.py 2012-11-30 12:43:36 +0000
@@ -27,9 +27,10 @@
2727
28import dbus.service28import dbus.service
29try:29try:
30 from gi.repository import GObject30 from gi.repository import GObject, GLib
31except ImportError:31except ImportError:
32 import gobject as GObject32 import gobject as GObject
33 import glib as GLib
3334
34from bzrlib.plugins.dbus import mapper35from bzrlib.plugins.dbus import mapper
35from bzrlib.revision import NULL_REVISION36from bzrlib.revision import NULL_REVISION
@@ -119,7 +120,7 @@
119 # make a non-blocking call, which we can then ignore as we dont120 # make a non-blocking call, which we can then ignore as we dont
120 # care about responses: Apparently there is some dbus foo to help121 # care about responses: Apparently there is some dbus foo to help
121 # make this not need the stub function122 # make this not need the stub function
122 mainloop = GObject.MainLoop()123 mainloop = GLib.MainLoop()
123 def handle_reply():124 def handle_reply():
124 # quit our loop.125 # quit our loop.
125 mainloop.quit()126 mainloop.quit()
@@ -162,7 +163,7 @@
162 is ready to handle requests.163 is ready to handle requests.
163 """164 """
164 broadcaster = Broadcast(self.bus)165 broadcaster = Broadcast(self.bus)
165 mainloop = GObject.MainLoop()166 mainloop = GLib.MainLoop()
166 if when_ready:167 if when_ready:
167 when_ready()168 when_ready()
168 mainloop.run()169 mainloop.run()
@@ -239,7 +240,7 @@
239 """240 """
240 self.bus = _get_bus(bus)241 self.bus = _get_bus(bus)
241 if mainloop is None:242 if mainloop is None:
242 self.mainloop = GObject.MainLoop()243 self.mainloop = GLib.MainLoop()
243 else:244 else:
244 self.mainloop = mainloop245 self.mainloop = mainloop
245 if activity is None:246 if activity is None:
@@ -328,7 +329,7 @@
328 self.port = self.sock.getsockname()[1]329 self.port = self.sock.getsockname()[1]
329 else:330 else:
330 self.port = _port331 self.port = _port
331 GObject.io_add_watch(self.sock, GObject.IO_IN, self.handle_network_packet)332 GLib.io_add_watch(self.sock, GLib.PRIORITY_HIGH, GLib.IO_IN, self.handle_network_packet)
332 # listen for dbus events333 # listen for dbus events
333 self.activity.listen_for_revisions(self.catch_dbus_revision)334 self.activity.listen_for_revisions(self.catch_dbus_revision)
334335
335336
=== modified file 'tests/test_activity.py'
--- tests/test_activity.py 2012-01-31 20:07:01 +0000
+++ tests/test_activity.py 2012-11-30 12:43:36 +0000
@@ -31,10 +31,10 @@
31import dbus.bus31import dbus.bus
32import dbus.mainloop.glib32import dbus.mainloop.glib
33try:33try:
34 from gi.repository import GObject34 from gi.repository import GObject, GLib
35except ImportError:35except ImportError:
36 import gobject as GObject36 import gobject as GObject
3737 import glib as GLib
3838
39import bzrlib.plugins39import bzrlib.plugins
40from bzrlib.smart.protocol import _encode_tuple, _decode_tuple40from bzrlib.smart.protocol import _encode_tuple, _decode_tuple
@@ -275,7 +275,7 @@
275 dbus_iface.announce_revision('revision2', 'url2',275 dbus_iface.announce_revision('revision2', 'url2',
276 reply_handler=handle_reply,276 reply_handler=handle_reply,
277 error_handler=handle_error)277 error_handler=handle_error)
278 mainloop = GObject.MainLoop()278 mainloop = GLib.MainLoop()
279 mainloop.run()279 mainloop.run()
280 if errors:280 if errors:
281 raise errors[0]281 raise errors[0]
@@ -349,7 +349,7 @@
349 dbus_iface.announce_revision_urls('revision2', ['url2'],349 dbus_iface.announce_revision_urls('revision2', ['url2'],
350 reply_handler=handle_reply,350 reply_handler=handle_reply,
351 error_handler=handle_error)351 error_handler=handle_error)
352 mainloop = GObject.MainLoop()352 mainloop = GLib.MainLoop()
353 mainloop.run()353 mainloop.run()
354 if errors:354 if errors:
355 raise errors[0]355 raise errors[0]
@@ -408,7 +408,7 @@
408 dbus_iface.add_url_map('foo/', 'baz/',408 dbus_iface.add_url_map('foo/', 'baz/',
409 reply_handler=handle_reply,409 reply_handler=handle_reply,
410 error_handler=handle_error)410 error_handler=handle_error)
411 mainloop = GObject.MainLoop()411 mainloop = GLib.MainLoop()
412 mainloop.run()412 mainloop.run()
413 if errors:413 if errors:
414 raise errors[0]414 raise errors[0]
@@ -450,7 +450,7 @@
450 dbus_iface.remove_url_map('foo/', 'baz/',450 dbus_iface.remove_url_map('foo/', 'baz/',
451 reply_handler=handle_reply,451 reply_handler=handle_reply,
452 error_handler=handle_error)452 error_handler=handle_error)
453 mainloop = GObject.MainLoop()453 mainloop = GLib.MainLoop()
454 mainloop.run()454 mainloop.run()
455 if errors:455 if errors:
456 raise errors[0]456 raise errors[0]
@@ -472,7 +472,7 @@
472472
473 def test_run_binds(self):473 def test_run_binds(self):
474 self.error = None474 self.error = None
475 mainloop = GObject.MainLoop()475 mainloop = GLib.MainLoop()
476 # we want run to: open a listening socket on localhost:4155 udp, the476 # we want run to: open a listening socket on localhost:4155 udp, the
477 # bzr protocol port number.477 # bzr protocol port number.
478 # to test this we want to check the port is in use during the loop.478 # to test this we want to check the port is in use during the loop.
@@ -485,8 +485,8 @@
485 except Exception, e:485 except Exception, e:
486 self.error = e486 self.error = e
487 finally:487 finally:
488 GObject.timeout_add(0, mainloop.quit)488 GLib.timeout_add(0, mainloop.quit)
489 GObject.timeout_add(0, check_socket_bound)489 GLib.timeout_add(0, check_socket_bound)
490 gateway = activity.LanGateway(self.bus, mainloop)490 gateway = activity.LanGateway(self.bus, mainloop)
491 # disable talking to dbus by making it a noop491 # disable talking to dbus by making it a noop
492 gateway.activity.listen_for_revisions = lambda x:x492 gateway.activity.listen_for_revisions = lambda x:x
@@ -495,7 +495,7 @@
495 raise self.error495 raise self.error
496496
497 def test_network_packets_trigger_handle_network_packet(self):497 def test_network_packets_trigger_handle_network_packet(self):
498 mainloop = GObject.MainLoop()498 mainloop = GLib.MainLoop()
499 # we want network packets to call handle_network_packet,499 # we want network packets to call handle_network_packet,
500 # so we override that to shutdown the mainloop and log the call.500 # so we override that to shutdown the mainloop and log the call.
501 def send_packet():501 def send_packet():
@@ -503,13 +503,13 @@
503 sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)503 sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
504 sock.sendto('data_to_handle', ('127.0.0.1', gateway.port))504 sock.sendto('data_to_handle', ('127.0.0.1', gateway.port))
505 sock.close()505 sock.close()
506 GObject.timeout_add(0, send_packet)506 GLib.timeout_add(0, send_packet)
507 GObject.timeout_add(1000, mainloop.quit)507 GLib.timeout_add(1000, mainloop.quit)
508 gateway = activity.LanGateway(self.bus, mainloop)508 gateway = activity.LanGateway(self.bus, mainloop)
509 calls = []509 calls = []
510 def handle_data(data):510 def handle_data(data):
511 calls.append(('handle', data))511 calls.append(('handle', data))
512 GObject.timeout_add(0, mainloop.quit)512 GLib.timeout_add(0, mainloop.quit)
513 gateway.handle_network_data = handle_data513 gateway.handle_network_data = handle_data
514 # disable talking to dbus by making it a noop514 # disable talking to dbus by making it a noop
515 gateway.activity.listen_for_revisions = lambda x:x515 gateway.activity.listen_for_revisions = lambda x:x
@@ -519,7 +519,7 @@
519 def test_broadcast_data_calls_sock(self):519 def test_broadcast_data_calls_sock(self):
520 # the method broadcast_data on a LanGateway should invoke520 # the method broadcast_data on a LanGateway should invoke
521 # socket.sendto(data, ('<broadcast>', 4155))521 # socket.sendto(data, ('<broadcast>', 4155))
522 mainloop = GObject.MainLoop()522 mainloop = GLib.MainLoop()
523 gateway = activity.LanGateway(self.bus, mainloop)523 gateway = activity.LanGateway(self.bus, mainloop)
524 calls = []524 calls = []
525 class StubSocket(object):525 class StubSocket(object):
@@ -531,8 +531,8 @@
531 calls)531 calls)
532532
533 def test_run_listens_for_revisions(self):533 def test_run_listens_for_revisions(self):
534 mainloop = GObject.MainLoop()534 mainloop = GLib.MainLoop()
535 GObject.timeout_add(0, mainloop.quit)535 GLib.timeout_add(0, mainloop.quit)
536 # avoid asking dbus if something is subscribed.536 # avoid asking dbus if something is subscribed.
537 class StubActivity(object):537 class StubActivity(object):
538 def listen_for_revisions(self, callback):538 def listen_for_revisions(self, callback):
@@ -545,7 +545,7 @@
545545
546 def test_catch_dbus_revision_ignore_file_only(self):546 def test_catch_dbus_revision_ignore_file_only(self):
547 """catch_dbus_revision should ignore file:/// urls."""547 """catch_dbus_revision should ignore file:/// urls."""
548 mainloop = GObject.MainLoop()548 mainloop = GLib.MainLoop()
549 gateway = activity.LanGateway(self.bus, mainloop)549 gateway = activity.LanGateway(self.bus, mainloop)
550 # instrument the transmission apis used by the LanGateway.550 # instrument the transmission apis used by the LanGateway.
551 calls = []551 calls = []
@@ -557,7 +557,7 @@
557557
558 def test_catch_dbus_revision_strip_file(self):558 def test_catch_dbus_revision_strip_file(self):
559 """catch_dbus_revision should strip file:/// urls if others exist."""559 """catch_dbus_revision should strip file:/// urls if others exist."""
560 mainloop = GObject.MainLoop()560 mainloop = GLib.MainLoop()
561 gateway = activity.LanGateway(self.bus, mainloop)561 gateway = activity.LanGateway(self.bus, mainloop)
562 # instrument the transmission apis used by the LanGateway.562 # instrument the transmission apis used by the LanGateway.
563 calls = []563 calls = []
@@ -572,7 +572,7 @@
572572
573 def test_catch_dbus_revision_encodes_smart_tuple(self):573 def test_catch_dbus_revision_encodes_smart_tuple(self):
574 """catch_dbus_revision should encode as _encode_tuple does."""574 """catch_dbus_revision should encode as _encode_tuple does."""
575 mainloop = GObject.MainLoop()575 mainloop = GLib.MainLoop()
576 gateway = activity.LanGateway(self.bus, mainloop)576 gateway = activity.LanGateway(self.bus, mainloop)
577 # instrument the transmission apis used by the LanGateway.577 # instrument the transmission apis used by the LanGateway.
578 calls = []578 calls = []
@@ -587,7 +587,7 @@
587587
588 def test_catch_dbus_revision_ignores_revision_url_all_from_network(self):588 def test_catch_dbus_revision_ignores_revision_url_all_from_network(self):
589 """There is a time limited window within which revisions are remembered."""589 """There is a time limited window within which revisions are remembered."""
590 mainloop = GObject.MainLoop()590 mainloop = GLib.MainLoop()
591 gateway = activity.LanGateway(self.bus, mainloop)591 gateway = activity.LanGateway(self.bus, mainloop)
592 # instrument the transmission apis used by the LanGateway.592 # instrument the transmission apis used by the LanGateway.
593 calls = []593 calls = []
@@ -601,7 +601,7 @@
601601
602 def test_catch_dbus_revision_preserves_non_network_urls(self):602 def test_catch_dbus_revision_preserves_non_network_urls(self):
603 """When some urls for a revision were not from the network the rest are sent."""603 """When some urls for a revision were not from the network the rest are sent."""
604 mainloop = GObject.MainLoop()604 mainloop = GLib.MainLoop()
605 gateway = activity.LanGateway(self.bus, mainloop)605 gateway = activity.LanGateway(self.bus, mainloop)
606 # instrument the transmission apis used by the LanGateway.606 # instrument the transmission apis used by the LanGateway.
607 calls = []607 calls = []
@@ -618,7 +618,7 @@
618618
619 def test_catch_dbus_revision_notes_revision(self):619 def test_catch_dbus_revision_notes_revision(self):
620 """Revisions coming in from dbus are noted too, to prevent reemission."""620 """Revisions coming in from dbus are noted too, to prevent reemission."""
621 mainloop = GObject.MainLoop()621 mainloop = GLib.MainLoop()
622 gateway = activity.LanGateway(self.bus, mainloop)622 gateway = activity.LanGateway(self.bus, mainloop)
623 # instrument the transmission apis used by the LanGateway.623 # instrument the transmission apis used by the LanGateway.
624 calls = []624 calls = []
@@ -641,7 +641,7 @@
641 self.assertTrue(calls[0][1] <= finish)641 self.assertTrue(calls[0][1] <= finish)
642642
643 def test_note_network_revision(self):643 def test_note_network_revision(self):
644 mainloop = GObject.MainLoop()644 mainloop = GLib.MainLoop()
645 gateway = activity.LanGateway(self.bus, mainloop)645 gateway = activity.LanGateway(self.bus, mainloop)
646 now = time.time()646 now = time.time()
647 # noting the we've seen 'rev' now should cache it at minute granularity.647 # noting the we've seen 'rev' now should cache it at minute granularity.
@@ -650,7 +650,7 @@
650 gateway.seen_revisions)650 gateway.seen_revisions)
651651
652 def test_note_network_revision_trims_cache(self):652 def test_note_network_revision_trims_cache(self):
653 mainloop = GObject.MainLoop()653 mainloop = GLib.MainLoop()
654 gateway = activity.LanGateway(self.bus, mainloop)654 gateway = activity.LanGateway(self.bus, mainloop)
655 now = time.time()655 now = time.time()
656 # noting a time when there are stale entries should remove them.656 # noting a time when there are stale entries should remove them.
@@ -666,7 +666,7 @@
666 def test_handle_network_data(self):666 def test_handle_network_data(self):
667 """data from the network is deserialised, passed to note_revision and dbus."""667 """data from the network is deserialised, passed to note_revision and dbus."""
668668
669 mainloop = GObject.MainLoop()669 mainloop = GLib.MainLoop()
670 # instrument the transmission apis used by the LanGateway.670 # instrument the transmission apis used by the LanGateway.
671 calls = []671 calls = []
672 start = time.time()672 start = time.time()

Subscribers

People subscribed via source and target branches