Page 1 of 1
Python 2.5 support abandoned?
Posted: Mon Feb 13, 2012 11:41 pm
by peekpeek
I'm stuck with Lenny, and upgrading to Python later than 2.5 is a HUGE pain since all the packages have to be recompiled. I started down that path, and gave up.
Instead I dug into Deluge 1.33 to see why it needed a Python newer than 2.5.
The changes seemed minor, so I wonder why support for Python 2.5 has been abandoned.
All I had to do was comment out the
Code: Select all
# with warnings.catch_warnings():
# warnings.simplefilter("ignore")
and move the follow line(s) indent back 4 spaces
At lines 87 and 110 of
ui/gtkui/torrentview.py
At line 262 of
ui/gtkui/filtertreeview.py
Then in filtertreeview.py I had to comment out the import glib, and remove the call to glib at line 290
Code: Select all
if pix:
# try:
return gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("%s16.png" % pix))
# except glib.GError as e:
# log.warning(e)
return self.get_transparent_pix(16, 16)
It looks like all these post Python 2.5 calls are just cosmetic changes to handle warnings?
Re: Python 2.5 support abandoned?
Posted: Tue Feb 14, 2012 12:11 am
by Cas
Thanks for picking that up, looks like my code changes where I forget about 2.5 compatibility.
At lines 87 and 110 of
ui/gtkui/torrentview.py
Can you try putting the following before the statement:
Code: Select all
from __future__ import with_statement
with warnings.catch_warnings():
warnings.simplefilter("ignore")
At line 262 of
ui/gtkui/filtertreeview.py
This one looks like a simple except syntax issue, fixed by replacing 'as' with ',':
Code: Select all
if pix:
try:
return gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("%s16.png" % pix))
except glib.GError, e:
log.warning(e)
return self.get_transparent_pix(16, 16)
Re: Python 2.5 support abandoned?
Posted: Tue Feb 14, 2012 1:58 am
by peekpeek
Problem with leaving in the try: gtk.gdk.pixbuf_new_from_file, is the glib.Gerror which requires the import glib which I don't have.
I do have python-gobject installed, but that doesn't seem to provide glib bindings in Lenny.
Re: Python 2.5 support abandoned?
Posted: Tue Feb 14, 2012 3:16 am
by Cas
Removing that try-except will cause deluge to crash if there is a problem with images at that point. Adding a try-except around the import glib would be a workaround but if this is isolated to lenny seems a bit pointless.
Re: Python 2.5 support abandoned?
Posted: Tue Feb 14, 2012 7:30 pm
by peekpeek
Cas wrote:Removing that try-except will cause deluge to crash if there is a problem with images at that point. Adding a try-except around the import glib would be a workaround but if this is isolated to lenny seems a bit pointless.
That's what the code was in 1.31, the try except with glib was added in 1.32
Nothing wrong with having the check for the png load failure and using the dummy image instead, the problem is using glib for the exception error (this is the only place in Deluge it's used).
Would something like this work instead?
Code: Select all
if pix:
try:
return gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("%s16.png" % pix))
except Exception, e:
log.warning(e)
return self.get_transparent_pix(16, 16)
Also it appears glib is not built into Ubuntu handy either
http://code.google.com/p/gphotoframe/issues/detail?id=4
Re: Python 2.5 support abandoned?
Posted: Tue Feb 14, 2012 8:17 pm
by peekpeek
Cas wrote:
Can you try putting the following before the statement:
Code: Select all
from __future__ import with_statement
with warnings.catch_warnings():
warnings.simplefilter("ignore")
I get this error if I try that:
File "/usr/lib/python2.5/site-packages/deluge-1.3.3-py2.5.egg/deluge/ui/gtkui/torrentview.py", line 87
from __future__ import with_statement
SyntaxError: from __future__ imports must occur at the beginning of the file
If I put the from __future__ import with_statement at the very top before all other imports, then no error.
That looks like a much simpler fix!
I also changed the import glib, glib.Gerror to just use Exception, and that seems to work as well.
Re: Python 2.5 support abandoned?
Posted: Tue Feb 14, 2012 8:26 pm
by peekpeek
peekpeek wrote:If I put the from __future__ import with_statement at the very top before all other imports, then no error.
Oh well, it causes problems, for instance with treefilterview.py line 263, at
pix = model.get_value(row, 4) I get object has no attribute 'catch_warnings', and the filter tree view has all it's label text missing.
If I comment out the with warnings.catch_warnings() the filter tree view text is correctly there.
Re: Python 2.5 support abandoned?
Posted: Tue Feb 14, 2012 9:04 pm
by Cas
Using Exception instead of glib seems reasonable.
Could you try the solution here for the warnings issue:
http://stackoverflow.com/questions/2059 ... python-2-6
Re: Python 2.5 support abandoned?
Posted: Tue Feb 14, 2012 10:53 pm
by peekpeek
Works fine, here is the code from torrentview.py:
Code: Select all
original_filters = warnings.filters[:]
#Supress Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed
warnings.simplefilter("ignore")
try:
if cell.get_property("pixbuf") != icon:
cell.set_property("pixbuf", icon)
finally:
warnings.filters = original_filters
And from filtertreeview.py:
Code: Select all
original_filters = warnings.filters[:]
#Supress Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed
warnings.simplefilter("ignore")
try:
pix = model.get_value(row, 4)
finally:
warnings.filters = original_filters
I hope this, and the Exception instead of Glib can make it into next build.
Speaking of suppressing warnings, I get a huge number of libglade-WARNING unknown property 'orientation' for class 'GtkVBox'
Looks like all the .glade files are full of
<property name="orientation">vertical</property>
Can we remove those since they are all the default, and only supported by newer versions?
Re: Python 2.5 support abandoned?
Posted: Wed Feb 15, 2012 2:20 am
by Cas
peekpeek wrote:Looks like all the .glade files are full of <property name="orientation">vertical</property>
Can we remove those since they are all the default, and only supported by newer versions?
No problem and I'll push these changes when I get a chance.