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
=== modified file 'bindings/python/Dee.py'
--- bindings/python/Dee.py 2012-08-15 13:36:15 +0000
+++ bindings/python/Dee.py 2012-09-11 14:43:23 +0000
@@ -40,7 +40,7 @@
40 Dee.Model.__init__(self)40 Dee.Model.__init__(self)
4141
42 def set_schema (self, *args):42 def set_schema (self, *args):
43 self.set_schema_full (tuple(args), len(args))43 self.set_schema_full (tuple(args))
44 44
45 def _build_row (self, args):45 def _build_row (self, args):
46 result = []46 result = []
4747
=== modified file 'examples/slave-model.py'
--- examples/slave-model.py 2011-02-09 03:44:27 +0000
+++ examples/slave-model.py 2012-09-11 14:43:23 +0000
@@ -31,16 +31,17 @@
31 self.model.connect("row-added", self.on_row_added, None)31 self.model.connect("row-added", self.on_row_added, None)
3232
33 def print_row (self, model, iter):33 def print_row (self, model, iter):
34 i = 0
34 while i < self.model.get_n_columns ():35 while i < self.model.get_n_columns ():
35 s = str(self.model.get_value (model, iter, i))36 s = str(self.model.get_value (iter, i))
36 if (i == 0):37 if (i == 0):
37 print "ADDED: %s" % s38 print "ADDED: %s" % s
38 else:39 else:
39 print ", %s" % s40 print ", %s" % s
40 i = i + 141 i = i + 1
4142
42 def on_row_added(self, model, iter):43 def on_row_added(self, model, iter, data):
43 print_row(model, iter)44 self.print_row(model, iter)
4445
45if __name__ == "__main__":46if __name__ == "__main__":
4647

Subscribers

People subscribed via source and target branches

to all changes: