Weird error in html5lib module
#1
Hi guys and gals. I use the latest Kodi version (Leia 18.4) and when I try to use the plugin I try to develop, I got a weird error in the html5lib module. The error is being thrown when I try to create the etree object:
python:
tree=html5lib.treebuilders.getTreeBuilder("etree")
The error is the following (partly talen from the Kodi log): https://paste.kodi.tv/rezexetixu.kodi
Needless to say that this part of the code run smoothly when I try to debug it in my PC, I have all the dependencies installed and I already tried to reinstall the html5lib module, as well as to get a clear installation of the Kodi.
Does anyone is familiar with such error?
Many thanks!
Reply
#2
the html5lib in kodi repo is very old and most likely not the version you get from pip
Reply
#3
(2019-10-01, 09:44)V8MEM Wrote: the html5lib in kodi repo is very old and most likely not the version you get from pip
Nope. I tried to put the latest html5lib coder (with minor modifications) inside my project instead using the Kodi's module (I know, not the most elegant way, but made it just for the test), but I got the same error.

Another update: I tried to create a dummy etree object inside the plugin code logic, and on the first (main page call, XFILE::CPluginDirectory::StartScript - calling plugin MyPlugin('plugin://plugin.my_plugin/','1','','resume:false') ) it does creates the tree, while on a second call to the file (XFILE::CPluginDirectory::StartScript - calling plugin MyPlugin('plugin://plugin.my_plugin/show_programs/-14/_first_run','2','','resume:false') ) it cannot create the tree anymore and throws that exception. Now I am stuck here Sad
Reply
#4
Another update: I successfully learned how to debug with the Web-PDB tool (very cool tool, kudos to its developer). When I reach the problematic line inside the etree.py code
python:
def getETreeBuilder(ElementTreeImplementation, fullTree=False):
    ElementTree = ElementTreeImplementation
    ElementTreeCommentType = ElementTree.Comment("asd").tag
if I try to manually call the ElementTree.Comment object, in both cases I receive <__builtin__.CommentProxy instance at 0x00000000050C4548>, but when I actually call for the function with the argument "asd" I got *** TypeError: 'NoneType' object is not callable error in Kodi, while on my PC debugger I got <Element <function Comment at 0x00000000054D65F8> at 0x0000000007753A20> element (as expected).
Reply
#5
Final update. In _utills.py instead of
python:
try:
    import xml.etree.cElementTree as default_etree
except ImportError:
    import xml.etree.ElementTree as default_etree
I put the direct, non-compiled import 
python:
import xml.etree.ElementTree as default_etree
It is a bit slower, but at least now it works. I still don't know what caused that peculiar error.
Reply

Logout Mark Read Team Forum Stats Members Help
Weird error in html5lib module0