Bug in the python bindings?
#1
hi.

was looking at tvnu.py to add some features but decided that it was easier to rewrite from scratch instead. the script is working well, if you're very lucky or reboot and run a hundred times or so.
when i press the 'a' button on a entry in the list the oncontrol method is called and i do the comparation if the control equals the list with channels i have. the xbmc.log will give me this error message:
01-12-2004 05:20:49 info q:\scripts\autoexec.py:212: runtimewarning: tp_compare didn't return -1 or -2 for exception

this problem can be trigged in the original tvnu.py too when moving around in the menues.

if one is very lucky and don't get that error message in the log everything works like it's supposed to.

i talked to darkie on irc last night and he told me something about python had already crashed when it reached that line of code (tvnu.py:214 or tvnu2.py:204). since this information is only available to ppl who have the developer version of xbmc (why?!?!?!?) it doesn't help me really much.
i tried to remove code until it worked but to no success. today i rewrote the parsing code not to use sgmlparser but instead a bunch of regexps, this also crashes.

the script using sgmlparser can be found at http://www.nittionio.nu/tvnu.py.txt (sgmlparser)
http://www.nittionio.nu/tvnu2.py.txt (regexp)
does't matter what version of the script, same problem

load it and press the 'a' button on a entry. you will most likly not be able to exit the script unless everything works perfectly. if this is the case, reboot and see it freeze Wink.

(this script is under development is not for mere mortals, when this bug has been resolved a final version will be made pretty soon)
Reply
#2
Big Grin 
i have found that instead of restarting the xbox literally a hundred times (which btw blew my sodding alladin chip!!!Wink, it is better to make a few changes to the script, so it doesn't lock up the xbox.

it appears that xbmc somehow isn't too happy about unhandled exceptions thrown back from the event handlers. so i have successfully added an exception handler to my onaction events like this:

Quote:    def onaction(self, action):
       try:
           # body of your implementation goes here
       except:
           self.flbstatus.addlabel("error/onaction: " + str(sys.exc_info()[0]))
           traceback.print_exc()

(this of course assumes that you have a controlfadelabel named self.flbstatus, and that you have imported the traceback module.)

the first line of the exception handler displays the class of the exception in the controlfadelabel, so the user/developer knows something went wrong. the second line prints the exception details to the console, i.e. exception message and call stack.

this should give you ample oppurtunity to close down your script properly, and then switch over to the console output.

since i started doing this in my own scripts, i haven't had to restart the xbox once because of a hanging script.

unhandled exceptions? just say no!  :talktohand:

another thing is that i have also found that lack of closing progress dialogs due to exceptions, will also make the xbox hang. so the safest way to display a progress dialog is something like this:

Quote:        dialog = xbmcgui.dialogprogress()
       dialog.create("title", "doing something.", "please wait...")
       try:
           # here goes some code that might throw an exception
       finally:
           dialog.close()

this way, you are always sure that the progress dialog will be closed, no matter what.
Reply
#3
ah.. thanks. i was under the impression that errors like thease (got nameerror because action_* was not defined) should be printed out in the log like other python errors.
catching the exceptions now which reviled the problem that caused the script to malfunction.

still.. xbmc really should put more extensive error reporting in the xbmc.log regarding python.
Reply
#4
i agree with you 100%.

turning the xbox on and off every 5 minutes, was potentially driving me nuts.  :nuts:  especially when this lead to my chip breaking.
Reply
#5
just a quick reply on it.
there is no way for me to add more / better error reporting to python. unless you know a know a better way i'll be happy to implement it.

about scripts that are crashing. can't do much about it. it 's the scripts writer responsibility to have try's and catches at the right places in your script in my opinion.

maybe there is a way to close all dialogs and such when a script is going to crash, but i haven't looked into this
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply

Logout Mark Read Team Forum Stats Members Help
Bug in the python bindings?0