Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix possible uncaught exception in _fetch_tvshows_recommended #14

Open
wants to merge 6 commits into from

5 participants

@jparyani

Fix possible exception in _fetch_tvshows_recommended when json query for when
a show returns no results. Also clean up the logic a bit

@MartijnKaijser

did you actually experienced that it failed?
There are ten-thousands of this script running and no one has ever complained about this so i don't see the point of changing it

@jparyani

Sorry, yes this is an error I encountered. It's probably a bug upstream with "inprogress" being marked for shows that are completely done, or it may be due to a weird edge case for me because I have multiple copies of each episode with different qualities (ie. 480p/720p/1080p).

If you want, I can send logs to better document what's going on, and we can fix it in a different place if that's more agreeable to you.

@jparyani

Any chance of getting this accepted? I've been manually patching my local version to get around this, and I'd love to have it fixed upstream. I also recently saw someone else having the same problem (http://forum.xbmc.org/showthread.php?tid=142389&pid=1443511#pid1443511), so I know it's not something unique to my installation.

@MilhouseVH

I've just seen this too after watching the last unwatched episode in a tvshow such that json_query2 returns:

{u'jsonrpc': u'2.0', u'id': u'1', u'result': {u'limits': {u'start': 0, u'total': 0, u'end': 0}}}

and since there is no episodes key the logic barrels into the item2 code in line 261 which then blows up because item2 is being used before it is assigned a value. Here's the exception:

13:51:23 T:2946196560   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.UnboundLocalError'>
                                            Error Contents: local variable 'item2' referenced before assignment
                                            Traceback (most recent call last):
                                              File "/storage/.xbmc/addons/service.skin.widgets/default.py", line 771, in onPlayBackEnded
                                                self.onPlayBackStopped()
                                              File "/storage/.xbmc/addons/service.skin.widgets/default.py", line 777, in onPlayBackStopped
                                                self.action('episode')
                                              File "/storage/.xbmc/addons/service.skin.widgets/default.py", line 631, in _update
                                                self._fetch_tvshows_recommended('RecommendedEpisode')
                                              File "/storage/.xbmc/addons/service.skin.widgets/default.py", line 261, in _fetch_tvshows_recommended
                                                if (item2['resume']['position'] and item2['resume']['total']) > 0:
                                            UnboundLocalError: local variable 'item2' referenced before assignment
                                            -->End of Python script error report<--

And I'm getting this error even though Recommended is disabled, which makes me wonder why this function is being executed at all (stock Confluence, so Recommended not supported). Checking if "Recommended" (or "Random Items" or "Recent Items") is enabled would avoid unnecessary queries and processing.

There are ten-thousands of this script running and no one has ever complained about this so i don't see the point of changing it

Maybe it's a timing issue, we all know the watched status is lazily set in a separate thread so possibly it's by chance that this error occurs when the watched status is actually set before json_query2 executes returning no episodes which the code doesn't allow for. Even if you don't agree the bug is likely to happen often (and it probably doesn't) the code is clearly flawed in the way it is structured as a code path does exist that will reference item2 before it is assigned a value.

@Rippert

I have just experienced this error, and Jason Paryani's patch fixed it. I'm using Gotham from Jan 04,2014 on Ubuntu. I guess I don't see the problem with accepting the commit since it fixes a confirmed bug. Do you dislike something about the way the patch is coded?

@StormTrooper

I am also having this problem. How do I go about applying this patch? I can't find a file called properties.py?

Unfortunately development of service.skin.widgets upstream project has moved from github to sourceforge http://sourceforge.net/p/xbmc/scripts/ci/ca653b291ae3f9390723eaddabea17a49a4a1213/tree/service.skin.widgets/ and I've been way behind on catching up to their changes.

A quick hack is to just download my repository as a zip, delete the current 'service.skin.widgets' directory, and replace it with this one. Then edit addon.xml's version to be "0.0.29" or higher to make sure it doesn't get overwritten in an auto update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.