dee

Code review comment for lp:~mvo/dee/small-python-fixes

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 = []

« Back to merge proposal