MilhouseVH / texturecache.py

Utility script to manage the XBMC texture cache
http://forum.xbmc.org/showthread.php?tid=158373
GNU General Public License v2.0
181 stars 34 forks source link

Fix if 'data' variable is a bytes-like object (decode utf-8 string) #13

Closed Holzhaus closed 10 years ago

Holzhaus commented 10 years ago

When running ./texturecache c i got this error:

Traceback (most recent call last):                
  File "./texturecache.py", line 7168, in <module>
    main(sys.argv[1:])
  File "./texturecache.py", line 7011, in main
    extraFields=_extraFields, query=_query)
  File "./texturecache.py", line 3708, in jsonQuery
    lastRun=lastRun, secondaryFields=secondaryFields, uniquecast=UCAST)
  File "./texturecache.py", line 2583, in getData
    self.getDataProxy(mediatype, REQUEST, trim_cast_thumbs=(action != "dump"), uniquecast=uniquecast))
  File "./texturecache.py", line 2596, in getDataProxy
    data = self.chunkedLoad(mediatype, request, trim_cast_thumbs, idname=idname, silent=silent, uniquecast=uniquecast)
  File "./texturecache.py", line 2635, in chunkedLoad
    data = self.sendJSON(request, idname)
  File "./texturecache.py", line 1708, in sendJSON
    for m in self.parseResponse(udata):
  File "./texturecache.py", line 1798, in parseResponse
    idx = _w(data, 0).end()
TypeError: can't use a string pattern on a bytes-like object

This commit is fixing the issue.

MilhouseVH commented 10 years ago

Hi. Presumably you are using Python3? Do you have any sample data that provokes this issue?

I'm of the feeling that performing the decode before the call to parseResponse() would be better, in fact this is already attempted (though perhaps not entirely - it doesn't check for bytes) at lines #1694-1700.

Could you try and determine why the decode isn't happening already?