2018-03-25, 15:01
I've discovered a bug in Kodi Python. If a function has kwargs but you call the function with some positional values followed by kwargs, the interpreter declares an error stating that too many arguments were given.
The class definition:
class RowItem(xbmcgui.ControlGroup):
def init(self, X=0, Y=0, width=380 , height=280, bgdSegmented=False, textColor='0xFFFFFF00',
bgdColor='0xFFFF0000', alignment=JUSTIFY_CENTER, font='font12'):
Code instantiating the class:
item = RowItem(X,rowY,width,height,bgdSegmented=False,bgdColor='0xFFFF00FF',
alignment=0)
Error message in the log:
"/storage/.kodi/addons/service.ltvpl/addon.py", line 198, in PlaylistConstructor
alignment=0)
TypeError: function takes at most 4 arguments (7 given)
Clearly, all of the arguments defined in init are kwargs except the first. Why did Kodi Python think that there are 4 positional parameters and why did it reject the kw parameters as being excessive? In order to get the code to run, I had to eliminate the kwargs when instantiating the class. Obviously, doing that is not a proper solution.
By the way I specified xbmc.python version 2.24.0 in my addon.xml file.
In the for what it's worth department, I ran a modified version of the above code under Linux (Python 2.7.13) on the same system Kodi is running on and did not get any errors at all.
Has
Has anyone else experienced this bug?
The class definition:
class RowItem(xbmcgui.ControlGroup):
def init(self, X=0, Y=0, width=380 , height=280, bgdSegmented=False, textColor='0xFFFFFF00',
bgdColor='0xFFFF0000', alignment=JUSTIFY_CENTER, font='font12'):
Code instantiating the class:
item = RowItem(X,rowY,width,height,bgdSegmented=False,bgdColor='0xFFFF00FF',
alignment=0)
Error message in the log:
"/storage/.kodi/addons/service.ltvpl/addon.py", line 198, in PlaylistConstructor
alignment=0)
TypeError: function takes at most 4 arguments (7 given)
Clearly, all of the arguments defined in init are kwargs except the first. Why did Kodi Python think that there are 4 positional parameters and why did it reject the kw parameters as being excessive? In order to get the code to run, I had to eliminate the kwargs when instantiating the class. Obviously, doing that is not a proper solution.
By the way I specified xbmc.python version 2.24.0 in my addon.xml file.
In the for what it's worth department, I ran a modified version of the above code under Linux (Python 2.7.13) on the same system Kodi is running on and did not get any errors at all.
Has
Has anyone else experienced this bug?