Kodi Community Forum

Full Version: script.module.kodi-six - a library for creating Python 2/3 compatible addons
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Kodi Six (script.module.kodi-six) is an experimental library that I've created to simplify porting Kodi Python addons to Python 3. The library provides wrappers around xbmc* modules that normalize string handling in both Python 2 and Python 3 versions of Kodi API so that you don't need to use ad hoc string encoding and decoding in Python 2 - with Kodi Six Kodi API works the same way in both versions. Please read the Readme for more info.

Source code on GitHub: https://github.com/romanvm/kodi.six
so basically with help of your module we will be converting our python2 projects to python3 projects.
then we will add your module on top of it and it will handle string vs unicode conversion inside our python3 compatible addon so its compatible with python2 (pre kodi 19.0) ?
Also we need to handle other aspect of compatibility like using proper urllib etc.
I'm not sure what you are asking but kodi-six only normalizes string handling in Kodi Python API function/method arguments and return values. Everything else you need to do yourself.
I have released the new version 0.1.0 (back-ported to gotham branch as 0.0.4) with changes that should bring major start-up performance improvements, especially on low-CPU platforms like Pi. Previously, if, for example, you did from kodi_six import xbmc all classes and functions from xbmc module were patched on import regardless on if they were actually used in the code, which slowed down addon start-up. Now patching is done lazily only when a specific function or class is first used, so, e.g. if you call xbmc.log(), log() function is patched on the first call and reference to the patched function is stored for further usage.
Really stupid question, is this module in the kodi.tv repo so another Kodi device will be able to find and install this as a dependency?
Yes it is available in the Official Kodi Repository.
I recently pushed an update to an addon I maintain that uses Kodi-Six for python2/3 compatibility. Had two different users report errors where the debug logs points to the kodi-six module as being the source of a UnicodeDecode error. On both systems it's during an "xbmc.executeJSONRPC()" call. Below are both the debug logs

yowehuyisu.kodi (paste) - line 254
acoqakafes.kodi (paste) - line 1242

Anything jump out that could be the issue here? Anything I could do on my end to prevent these or is it an issue with kodi-six? I can make an issue on Github if this is more appropriate there.
(2019-09-08, 22:29)robweber Wrote: [ -> ]I recently pushed an update to an addon I maintain that uses Kodi-Six for python2/3 compatibility. Had two different users report errors where the debug logs points to the kodi-six module as being the source of a UnicodeDecode error. On both systems it's during an "xbmc.executeJSONRPC()" call. Below are both the debug logs

yowehuyisu.kodi (paste) - line 254
acoqakafes.kodi (paste) - line 1242

Anything jump out that could be the issue here? Anything I could do on my end to prevent these or is it an issue with kodi-six? I can make an issue on Github if this is more appropriate there.
I would love to see something happen with this as well...also having issues
There's not much that can be done if user's database contains textual information encoded not in UTF-8.
Here is the Issue on Github where we discussed this in more detail for those interested: https://github.com/romanvm/kodi.six/issues/3