0

I'm working on a project that runs in a Python environment with numerous C extensions included that are used to interface with the software that the project runs under. Unfortunately, the documentation for some of these functions is either incorrect or absent entirely, meaning I have no way of knowing what arguments I need to supply to the function.

As well as this, the error messages that I receive when calling the functions don't give many hints as to what the correct number and type of arguments are.

>>> # Standard Python function
>>> sys.stdout.print()
TypeError: function takes exactly 1 argument (0 given)
>>> sys.stdout.print(1)
TypeError: a bytes-like object is required, not 'int'
>>> # Python extension function
>>> custom_module.foo()
TypeError: Wrong number of function parameters or wrong parameter type

I also cannot use inspect.getargs() to get the expected arguments for the function, since I get the following exception:

>>> inspect.getargs(custom_module.foo)
TypeError: <built-in function foo> is not a code object

In essence, what is the best way for me to find the expected arguments for this function, since the documentation hasn't been updated in a reasonable time-frame?

Miguel Guthridge
  • 1,444
  • 10
  • 27

0 Answers0