joolswills / plugin.video.iplayer

This plugin is broken.
10 stars 4 forks source link

Patch: Avoid md5 and sets deprecation warnings on Pyton 2.6+ #149

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

On some platforms (eg. OUYA/Android) there will be deprecation warnings each 
time iplayer2.py or iplayer_search.py is loaded (respectively, "md5" and "sets" 
deprecation warnings).

Debug log output (http://pastebin.com/)

md5:
20:38:41 T:1820196704   ERROR: 
/storage/sdcard0/Android/data/org.xbmc.xbmc/files/.xbmc/addons/plugin.video.ipla
yer/lib/iplayer2.py:7: DeprecationWarning: the md5 module is deprecated; use 
hashlib instead
                                              import md5

sets:
20:38:42 T:1820196704   ERROR: 
/storage/sdcard0/Android/data/org.xbmc.xbmc/files/.xbmc/addons/plugin.video.ipla
yer/lib/iplayer_search.py:5: DeprecationWarning: the sets module is deprecated
                                              from sets import Set

What version of the plugin are you using? On what OS?

2.5.5 on Android (OUYA)

Please provide any additional information below.

The attached patch will prevent the warnings on Python 2.6+ platforms by only 
loading the deprecated modules on Python 2.5 or below.

It does raise the question of whether support for Python 2.5 and below should 
now be dropped as I don't think XBMC is built with anything less than 2.6, but 
I could be wrong.

Original issue reported on code.google.com by n...@nmacleod.com on 30 Apr 2014 at 10:23

Attachments:

GoogleCodeExporter commented 9 years ago
I've also just noticed that in iplayer_search::delete_search() there are a 
couple of print() statements that are probably meant to help with debugging 
that should be converted to utils.log() statements, or eliminated completely.

I've attached an updated patch with the two print() statements removed.

Original comment by n...@nmacleod.com on 30 Apr 2014 at 10:33

Attachments:

GoogleCodeExporter commented 9 years ago
added in r163 thanks.

Probably correct in that support for python 2.5 and lower is not needed. Even 
the upcoming release of xbmc on the xbox has python 2.7

No harm in leaving it in for now, but I guess at some point we can remove 
compatibility.

Original comment by exob...@gmail.com on 3 May 2014 at 5:57

GoogleCodeExporter commented 9 years ago
Re-opening as the patch doesn't look right. Also there are deprecation warnings 
on python 2.5 not just 2.6+

I think it should be

Index: lib/iplayer2.py
===================================================================
--- lib/iplayer2.py (revision 169)
+++ lib/iplayer2.py (working copy)
@@ -16,7 +16,7 @@
 import stations

 try:
-    from hashlib import _md5
+    from hashlib import md5 as _md5
 except:
     # use md5 for python 2.5 compat
     import md5

Original comment by exob...@gmail.com on 6 May 2014 at 8:16

GoogleCodeExporter commented 9 years ago
I have committed this change in r170 - please do get back to me if this seems 
ok.

Original comment by exob...@gmail.com on 6 May 2014 at 8:18

GoogleCodeExporter commented 9 years ago
Seems that we do need to support python 2.5 for now as it is in use by some 
Android users.

Original comment by exob...@gmail.com on 6 May 2014 at 8:20

GoogleCodeExporter commented 9 years ago
Eugh... the duff syntax of mine in the old patch is throwing an exception while 
importing hashlib, so consequently md5 is always imported... :(

Good catch, thanks for the fix.

Original comment by n...@nmacleod.com on 6 May 2014 at 8:33

GoogleCodeExporter commented 9 years ago

Original comment by exob...@gmail.com on 6 May 2014 at 9:36