dee

Merge lp:~mvo/dee/small-python-fixes into lp:dee

Proposed by Michael Vogt
Status: Rejected
Rejected by: Michal Hruby
Proposed branch: lp:~mvo/dee/small-python-fixes
Merge into: lp:dee
Diff against target: 36 lines (+5/-4)
2 files modified
bindings/python/Dee.py (+1/-1)
examples/slave-model.py (+4/-3)
To merge this branch: bzr merge lp:~mvo/dee/small-python-fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Unity Team Pending
Review via email: mp+123763@code.launchpad.net

Description of the change

This fixes the python examples in the source to work

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Thanks for these

8 - self.set_schema_full (tuple(args), len(args))
9 + self.set_schema_full (tuple(args))

Would be nice if pygobject didn't change something every other version :( Ideally there should be a way to make it work with new as well as old pygobject (doesn't pygobject provide it's version in some prop?)

Revision history for this message
Michael Vogt (mvo) wrote :

On Tue, Sep 11, 2012 at 02:53:30PM -0000, Michal Hruby wrote:
> Thanks for these
>
> 8 - self.set_schema_full (tuple(args), len(args))
> 9 + self.set_schema_full (tuple(args))
>
> Would be nice if pygobject didn't change something every other version :( Ideally there should be a way to make it work with new as well as old pygobject (doesn't pygobject provide it's version in some prop?)

Since recently there is a gi.version_info that could be used, but its
not available on precsie and I don't know when exactly it was added
(nor when exactly the bindings broke).

So I think there these options:

- simply require latest python-gi and change unconditionally

- I could do a try/except AttributeError but that carries the risk that
it shadows other errors so I'm not really advocating it.

- Something like:
=== modified file 'bindings/python/Dee.py'
--- bindings/python/Dee.py 2012-09-11 14:41:44 +0000
+++ bindings/python/Dee.py 2012-09-12 10:36:47 +0000
@@ -1,3 +1,4 @@
+import gi
 from gi.overrides import override
 from gi.importer import modules

@@ -40,7 +41,12 @@
         Dee.Model.__init__(self)

     def set_schema (self, *args):
- self.set_schema_full (tuple(args))
+ version = getattr(gi.version_info, None)
+ # mvo: I don't know when *exactly* this changed
+ if version and version[0] > 3 and version[1] > 3:
+ self.set_schema_full (tuple(args))
+ else:
+ self.set_schema_full (tuple(args), len(args))

     def _build_row (self, args):
         result = []

Revision history for this message
Michal Hruby (mhr3) wrote :

> On Tue, Sep 11, 2012 at 02:53:30PM -0000, Michal Hruby wrote:
> > Thanks for these
> >
> > 8 - self.set_schema_full (tuple(args), len(args))
> > 9 + self.set_schema_full (tuple(args))
> >
> > Would be nice if pygobject didn't change something every other version :(
> Ideally there should be a way to make it work with new as well as old
> pygobject (doesn't pygobject provide it's version in some prop?)
>
> Since recently there is a gi.version_info that could be used, but its
> not available on precsie and I don't know when exactly it was added
> (nor when exactly the bindings broke).
>
> So I think there these options:
>
> - simply require latest python-gi and change unconditionally
>
> - I could do a try/except AttributeError but that carries the risk that
> it shadows other errors so I'm not really advocating it.
>

As long as it works on both P and Q, I'm fine with it, we don't need to support every version combination... And +1 for avoiding the use of try except.

Could you also link a bug about this pls?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

I think this was fixed long time ago.

Unmerged revisions

380. By Michael Vogt

examples/slave-model.py: fix the example to actually work

379. By Michael Vogt

bindings/python/Dee.py: make set_schema() not crash

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bindings/python/Dee.py'
2--- bindings/python/Dee.py 2012-08-15 13:36:15 +0000
3+++ bindings/python/Dee.py 2012-09-11 14:43:23 +0000
4@@ -40,7 +40,7 @@
5 Dee.Model.__init__(self)
6
7 def set_schema (self, *args):
8- self.set_schema_full (tuple(args), len(args))
9+ self.set_schema_full (tuple(args))
10
11 def _build_row (self, args):
12 result = []
13
14=== modified file 'examples/slave-model.py'
15--- examples/slave-model.py 2011-02-09 03:44:27 +0000
16+++ examples/slave-model.py 2012-09-11 14:43:23 +0000
17@@ -31,16 +31,17 @@
18 self.model.connect("row-added", self.on_row_added, None)
19
20 def print_row (self, model, iter):
21+ i = 0
22 while i < self.model.get_n_columns ():
23- s = str(self.model.get_value (model, iter, i))
24+ s = str(self.model.get_value (iter, i))
25 if (i == 0):
26 print "ADDED: %s" % s
27 else:
28 print ", %s" % s
29 i = i + 1
30
31- def on_row_added(self, model, iter):
32- print_row(model, iter)
33+ def on_row_added(self, model, iter, data):
34+ self.print_row(model, iter)
35
36 if __name__ == "__main__":
37

Subscribers

People subscribed via source and target branches

to all changes: