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 |
Related bugs: |
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 PyGIDeprecation
Description of the change
Resolve Bug #1095884: "bzr showing PyGIDeprecation
Dimitri John Ledkov (xnox) wrote : | # |
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
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
Robert Bruce Park (robru) wrote : | # |
Works for me, too!
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.
-------
_StringException: Empty attachments:
log
Traceback (most recent call last):
File "/tmp/buildd/
gateway.
File "/tmp/buildd/
self.
File "/tmp/buildd/
GLib.
TypeError: third argument not callable
=======
ERROR: bzrlib.
-------
_StringException: Empty attachments:
log
Traceback (most recent call last):
File "/tmp/buildd/
gateway.
File "/tmp/buildd/
self.
File "/tmp/buildd/
GLib.
TypeError: third argument not callable
=======
ERROR: bzrlib.
-------
_StringException: Empty attachments:
log
Traceback (most recent call last):
File "/tmp/buildd/
gateway.
File "/tmp/buildd/
self.
File "/tmp/buildd/
GLib.
TypeError: third argument not callable
-------
Ran 37 tests in 1.092s
FAILED (errors=3)
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:/
(also, I think this branch is more complete, as it no longer imports gobject at all)
Thanks!
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.
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
Richard Wilbur (richard-wilbur) wrote : | # |
On Sun, Jan 27, 2013 at 2:21 PM, Robert Bruce Park
<email address hidden> wrote:
[...]
> https:/
>
> (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
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
1 | === modified file 'activity.py' |
2 | --- activity.py 2012-01-31 20:07:01 +0000 |
3 | +++ activity.py 2012-11-30 12:43:36 +0000 |
4 | @@ -27,9 +27,10 @@ |
5 | |
6 | import dbus.service |
7 | try: |
8 | - from gi.repository import GObject |
9 | + from gi.repository import GObject, GLib |
10 | except ImportError: |
11 | import gobject as GObject |
12 | + import glib as GLib |
13 | |
14 | from bzrlib.plugins.dbus import mapper |
15 | from bzrlib.revision import NULL_REVISION |
16 | @@ -119,7 +120,7 @@ |
17 | # make a non-blocking call, which we can then ignore as we dont |
18 | # care about responses: Apparently there is some dbus foo to help |
19 | # make this not need the stub function |
20 | - mainloop = GObject.MainLoop() |
21 | + mainloop = GLib.MainLoop() |
22 | def handle_reply(): |
23 | # quit our loop. |
24 | mainloop.quit() |
25 | @@ -162,7 +163,7 @@ |
26 | is ready to handle requests. |
27 | """ |
28 | broadcaster = Broadcast(self.bus) |
29 | - mainloop = GObject.MainLoop() |
30 | + mainloop = GLib.MainLoop() |
31 | if when_ready: |
32 | when_ready() |
33 | mainloop.run() |
34 | @@ -239,7 +240,7 @@ |
35 | """ |
36 | self.bus = _get_bus(bus) |
37 | if mainloop is None: |
38 | - self.mainloop = GObject.MainLoop() |
39 | + self.mainloop = GLib.MainLoop() |
40 | else: |
41 | self.mainloop = mainloop |
42 | if activity is None: |
43 | @@ -328,7 +329,7 @@ |
44 | self.port = self.sock.getsockname()[1] |
45 | else: |
46 | self.port = _port |
47 | - GObject.io_add_watch(self.sock, GObject.IO_IN, self.handle_network_packet) |
48 | + GLib.io_add_watch(self.sock, GLib.PRIORITY_HIGH, GLib.IO_IN, self.handle_network_packet) |
49 | # listen for dbus events |
50 | self.activity.listen_for_revisions(self.catch_dbus_revision) |
51 | |
52 | |
53 | === modified file 'tests/test_activity.py' |
54 | --- tests/test_activity.py 2012-01-31 20:07:01 +0000 |
55 | +++ tests/test_activity.py 2012-11-30 12:43:36 +0000 |
56 | @@ -31,10 +31,10 @@ |
57 | import dbus.bus |
58 | import dbus.mainloop.glib |
59 | try: |
60 | - from gi.repository import GObject |
61 | + from gi.repository import GObject, GLib |
62 | except ImportError: |
63 | import gobject as GObject |
64 | - |
65 | + import glib as GLib |
66 | |
67 | import bzrlib.plugins |
68 | from bzrlib.smart.protocol import _encode_tuple, _decode_tuple |
69 | @@ -275,7 +275,7 @@ |
70 | dbus_iface.announce_revision('revision2', 'url2', |
71 | reply_handler=handle_reply, |
72 | error_handler=handle_error) |
73 | - mainloop = GObject.MainLoop() |
74 | + mainloop = GLib.MainLoop() |
75 | mainloop.run() |
76 | if errors: |
77 | raise errors[0] |
78 | @@ -349,7 +349,7 @@ |
79 | dbus_iface.announce_revision_urls('revision2', ['url2'], |
80 | reply_handler=handle_reply, |
81 | error_handler=handle_error) |
82 | - mainloop = GObject.MainLoop() |
83 | + mainloop = GLib.MainLoop() |
84 | mainloop.run() |
85 | if errors: |
86 | raise errors[0] |
87 | @@ -408,7 +408,7 @@ |
88 | dbus_iface.add_url_map('foo/', 'baz/', |
89 | reply_handler=handle_reply, |
90 | error_handler=handle_error) |
91 | - mainloop = GObject.MainLoop() |
92 | + mainloop = GLib.MainLoop() |
93 | mainloop.run() |
94 | if errors: |
95 | raise errors[0] |
96 | @@ -450,7 +450,7 @@ |
97 | dbus_iface.remove_url_map('foo/', 'baz/', |
98 | reply_handler=handle_reply, |
99 | error_handler=handle_error) |
100 | - mainloop = GObject.MainLoop() |
101 | + mainloop = GLib.MainLoop() |
102 | mainloop.run() |
103 | if errors: |
104 | raise errors[0] |
105 | @@ -472,7 +472,7 @@ |
106 | |
107 | def test_run_binds(self): |
108 | self.error = None |
109 | - mainloop = GObject.MainLoop() |
110 | + mainloop = GLib.MainLoop() |
111 | # we want run to: open a listening socket on localhost:4155 udp, the |
112 | # bzr protocol port number. |
113 | # to test this we want to check the port is in use during the loop. |
114 | @@ -485,8 +485,8 @@ |
115 | except Exception, e: |
116 | self.error = e |
117 | finally: |
118 | - GObject.timeout_add(0, mainloop.quit) |
119 | - GObject.timeout_add(0, check_socket_bound) |
120 | + GLib.timeout_add(0, mainloop.quit) |
121 | + GLib.timeout_add(0, check_socket_bound) |
122 | gateway = activity.LanGateway(self.bus, mainloop) |
123 | # disable talking to dbus by making it a noop |
124 | gateway.activity.listen_for_revisions = lambda x:x |
125 | @@ -495,7 +495,7 @@ |
126 | raise self.error |
127 | |
128 | def test_network_packets_trigger_handle_network_packet(self): |
129 | - mainloop = GObject.MainLoop() |
130 | + mainloop = GLib.MainLoop() |
131 | # we want network packets to call handle_network_packet, |
132 | # so we override that to shutdown the mainloop and log the call. |
133 | def send_packet(): |
134 | @@ -503,13 +503,13 @@ |
135 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) |
136 | sock.sendto('data_to_handle', ('127.0.0.1', gateway.port)) |
137 | sock.close() |
138 | - GObject.timeout_add(0, send_packet) |
139 | - GObject.timeout_add(1000, mainloop.quit) |
140 | + GLib.timeout_add(0, send_packet) |
141 | + GLib.timeout_add(1000, mainloop.quit) |
142 | gateway = activity.LanGateway(self.bus, mainloop) |
143 | calls = [] |
144 | def handle_data(data): |
145 | calls.append(('handle', data)) |
146 | - GObject.timeout_add(0, mainloop.quit) |
147 | + GLib.timeout_add(0, mainloop.quit) |
148 | gateway.handle_network_data = handle_data |
149 | # disable talking to dbus by making it a noop |
150 | gateway.activity.listen_for_revisions = lambda x:x |
151 | @@ -519,7 +519,7 @@ |
152 | def test_broadcast_data_calls_sock(self): |
153 | # the method broadcast_data on a LanGateway should invoke |
154 | # socket.sendto(data, ('<broadcast>', 4155)) |
155 | - mainloop = GObject.MainLoop() |
156 | + mainloop = GLib.MainLoop() |
157 | gateway = activity.LanGateway(self.bus, mainloop) |
158 | calls = [] |
159 | class StubSocket(object): |
160 | @@ -531,8 +531,8 @@ |
161 | calls) |
162 | |
163 | def test_run_listens_for_revisions(self): |
164 | - mainloop = GObject.MainLoop() |
165 | - GObject.timeout_add(0, mainloop.quit) |
166 | + mainloop = GLib.MainLoop() |
167 | + GLib.timeout_add(0, mainloop.quit) |
168 | # avoid asking dbus if something is subscribed. |
169 | class StubActivity(object): |
170 | def listen_for_revisions(self, callback): |
171 | @@ -545,7 +545,7 @@ |
172 | |
173 | def test_catch_dbus_revision_ignore_file_only(self): |
174 | """catch_dbus_revision should ignore file:/// urls.""" |
175 | - mainloop = GObject.MainLoop() |
176 | + mainloop = GLib.MainLoop() |
177 | gateway = activity.LanGateway(self.bus, mainloop) |
178 | # instrument the transmission apis used by the LanGateway. |
179 | calls = [] |
180 | @@ -557,7 +557,7 @@ |
181 | |
182 | def test_catch_dbus_revision_strip_file(self): |
183 | """catch_dbus_revision should strip file:/// urls if others exist.""" |
184 | - mainloop = GObject.MainLoop() |
185 | + mainloop = GLib.MainLoop() |
186 | gateway = activity.LanGateway(self.bus, mainloop) |
187 | # instrument the transmission apis used by the LanGateway. |
188 | calls = [] |
189 | @@ -572,7 +572,7 @@ |
190 | |
191 | def test_catch_dbus_revision_encodes_smart_tuple(self): |
192 | """catch_dbus_revision should encode as _encode_tuple does.""" |
193 | - mainloop = GObject.MainLoop() |
194 | + mainloop = GLib.MainLoop() |
195 | gateway = activity.LanGateway(self.bus, mainloop) |
196 | # instrument the transmission apis used by the LanGateway. |
197 | calls = [] |
198 | @@ -587,7 +587,7 @@ |
199 | |
200 | def test_catch_dbus_revision_ignores_revision_url_all_from_network(self): |
201 | """There is a time limited window within which revisions are remembered.""" |
202 | - mainloop = GObject.MainLoop() |
203 | + mainloop = GLib.MainLoop() |
204 | gateway = activity.LanGateway(self.bus, mainloop) |
205 | # instrument the transmission apis used by the LanGateway. |
206 | calls = [] |
207 | @@ -601,7 +601,7 @@ |
208 | |
209 | def test_catch_dbus_revision_preserves_non_network_urls(self): |
210 | """When some urls for a revision were not from the network the rest are sent.""" |
211 | - mainloop = GObject.MainLoop() |
212 | + mainloop = GLib.MainLoop() |
213 | gateway = activity.LanGateway(self.bus, mainloop) |
214 | # instrument the transmission apis used by the LanGateway. |
215 | calls = [] |
216 | @@ -618,7 +618,7 @@ |
217 | |
218 | def test_catch_dbus_revision_notes_revision(self): |
219 | """Revisions coming in from dbus are noted too, to prevent reemission.""" |
220 | - mainloop = GObject.MainLoop() |
221 | + mainloop = GLib.MainLoop() |
222 | gateway = activity.LanGateway(self.bus, mainloop) |
223 | # instrument the transmission apis used by the LanGateway. |
224 | calls = [] |
225 | @@ -641,7 +641,7 @@ |
226 | self.assertTrue(calls[0][1] <= finish) |
227 | |
228 | def test_note_network_revision(self): |
229 | - mainloop = GObject.MainLoop() |
230 | + mainloop = GLib.MainLoop() |
231 | gateway = activity.LanGateway(self.bus, mainloop) |
232 | now = time.time() |
233 | # noting the we've seen 'rev' now should cache it at minute granularity. |
234 | @@ -650,7 +650,7 @@ |
235 | gateway.seen_revisions) |
236 | |
237 | def test_note_network_revision_trims_cache(self): |
238 | - mainloop = GObject.MainLoop() |
239 | + mainloop = GLib.MainLoop() |
240 | gateway = activity.LanGateway(self.bus, mainloop) |
241 | now = time.time() |
242 | # noting a time when there are stale entries should remove them. |
243 | @@ -666,7 +666,7 @@ |
244 | def test_handle_network_data(self): |
245 | """data from the network is deserialised, passed to note_revision and dbus.""" |
246 | |
247 | - mainloop = GObject.MainLoop() |
248 | + mainloop = GLib.MainLoop() |
249 | # instrument the transmission apis used by the LanGateway. |
250 | calls = [] |
251 | start = time.time() |
One left: Warning: Calling io_add_watch with a file object is deprecated; call it with a GLib.IOChannel object
PyGIDeprecation