This error is generated by the wrapper between the python and C libs that is automatically generated. The function that created this error message cna be found here 7.
This is called by the THPUtils_invalidArguments function from here 1.
This function is used in few places, in particular in the automatic wrapper cwrap that I was talking about above, here 3 or here 1 for example.