AttributeError: 'NoneType' object has no attribute 'getProperty'
Closed this issue ยท 30 comments
Tried to debug, but running into trouble straight away.
The log code is still broken in multiple places - it's (partially) fixed in xmlfunctions:
def log(txt):
if ADDON.getSetting( "enable_logging" ) == "true":
if sys.version_info.major == 2:
if isinstance (txt,str):
txt = txt.decode('utf-8')
message = u'%s: %s' % (ADDONID, txt)
if sys.version_info.major == 3:
xbmc.log(msg=message, level=xbmc.LOGDEBUG)
else:
xbmc.log(msg=message.encode('utf-8'), level=xbmc.LOGDEBUG)
(but shouldn't is be if not isinstance
- if it's not already plain text rather than unicode, decode it to plain text...? - I could well be wrong!) That needs to be every instance of def log. Then I should be able to see what I'm doing.
(Minor issue also, the string for 'Enable debug logging' in settings.xml has been changed at some point so now reads something about widgets.)
I'll make the changes locally, then see if I can recreate your problem.
Can't easily recreate the problem.
If I delete all from addon_data, open the menu editor, add a new item and set some properties, then disable that or a different item ... it all works ๐
It works for me too just the error in the log...
No error for you?
No error for me.
gui.py line 66 (in the is_hebrew function) should be if not isinstance(text, str):
- without that, changing labels is borked.
I guess it's not a problem then. Like I said everything works I just get that error in the log.
May i ask you if you have the fix for the logging?
I really don't get the encode decode stuff yet.
Is the way def try_decode does it correct?
I think it should be the same no matter whether we're on Py2 or Py3:
def log(txt):
if ADDON.getSetting( "enable_logging" ) == "true":
if not isinstance (txt,str):
txt = txt.decode('utf-8')
message = u'%s: %s' % (ADDONID, txt)
if sys.version_info.major == 3:
xbmc.log(msg=message, level=xbmc.LOGDEBUG)
else:
xbmc.log(msg=message.encode('utf-8'), level=xbmc.LOGDEBUG)
try_decode similarly should be using if not isinstance
, regardless of python version.
Ok IIRC at the beginning I tried copying some code from another script and that was apparently not the way to go ๐
Oops I think I deleted the
except
pass
and should not have...
Looks good ๐
And if I'm leading you up the garden path with if not isinstance
(which is quite possible), and if it helps (which it probably doesn't!) once you get it out for general testing, our international friends will soon tell us if it's wrong!
(The except/pass is bad practice anyway - it SHOULDN'T ever fail, except in cases like this where there are breaking changes anyway. It's just nice sometimes to say 'well, this is the best code I can write right now, and if it doesn't work we'll just ignore that anyway')
Awesome ๐
This is correct for try_decode?
def try_decode(text, encoding="utf-8"):
if not isinstance(text, str):
try:
return text.decode(encoding)
except:
pass
return text
Or remove the Except pass there too?
The try_decode is a massive bodge anyway (you might have gathered, all the encoding/decoding isn't straight forward!), so I'd probably leave the try catch block there just in case. But yes, that looks right.
Oh yeah wow that's much better with the logging. I forgot there was a setting separately from enabling the Kodi debug log.
Those darn Unable to generate hash errors are back... ๐ฆ
For the hebrew def I just wanna make sure that this is correct:
def is_hebrew(text):
if not isinstance(text, str):
text = text.decode('utf-8')
for chr in text:
if ord(chr) >= 1488 and ord(chr) <= 1514:
return True
return False
๐
Just tested on Leia 18.3 and everything seems to be working there as well.
I am still getting the
AttributeError: 'NoneType' object has no attribute 'getProperty'
Only when making lots of changes at once but it doesn't affect anything and the menu updates fine.
There is also no Unable to generate hash
errors like in the Matrix Python 3 build.
I think I need to encode the hasher.update but as soon as I add that I get a build loop.
Both my least favourite types of errors - ones I can't reproduce ;)
I've found a couple more errors, but I suspect they're going to be harder to fix. Want me to open individual issue's for them, or add them here?
But fantastic work on getting something working on both Py2 and 3 ๐
I'm not picky so anywhere that is easier for you works for me.
Yeah, I hate unreproducible errors. For me it is easy I just encode that and bam build loop.
Are you using the test_branch?
OK, I've opened new issues. I'll try to look at them myself, but my next opportunity is likely not going to be for some days.
Yes, using the test_branch. A while ago, Marcelveldt and I spent far too long trying to debug differences in hashing between Windows and Mac. We had to revert a great bit of code because Windows behaved weirdly. Hope its not that rearing its head again!
That sounds like it is too conspicuously coincidental for it not to be the same thing.
Maybe I can look back at what you guys were doing then and see if I notice something.
I'll review older issues and commits.
Do you happen to remember a commit name or something that might narrow down the search?
It's a long long time ago. I remember I was trying to streamline the hashing code. I remember that - on Windows - the hash of the file was changing between when I was generating the hash and when we then came to check the hash (which was resulting in a build loop because the hash of the file was always different from what we'd saved). And I remember being annoyed that I'd put the time in and had to revert it ๐
Still reading the PR but maybe this one?
There is mention of build loop and it was merged, not sure if it was reverted.
Just found it myself. Yup, that's the one. I was trying to replace the hashes with the file last modified time, but the time changed between finishing writing it and then reading it. So probably not related.
Darn.
Perhaps it is time for me to ask for assistance in the script thread and add-on dev forum...
@BobCratchett I figured out exactly what causes this error.
It is when the last item in list 211 is deleted and the focus jumps to the top of the list.
Adding xbmc.sleep(100) HERE fixes it.
Is that the correct way to fix it?
Just an FYI xbmc.sleep()
is depreciated afaik.
You should use xbmc.Monitor().waitForAbort(100)
instead.
No, it's not the correct way to fix it (I'm struggling to work out why there's a problem .getProperty'ing at the time, let alone why its fine 1sc later!). However, my time to actually debug and fix it properly is ridiculously limited at the moment (and the time I've been able to put into it so far hasn't come up with anything better), and it does fix it...
(edit @jurialmunkey - good to see you around. So many people seem to have moved on since I was last able to be actively involved, it's good to see some of the old guard still around :))
Re-open if issue persists with https://github.com/mikesilvo164/script.skinshortcuts/releases/tag/2.0.0.alpha2 or higher