Question

I was coding something at work and it seems that some C API functions provided by python are not working. I tried mainly the function that check types, for example:

import ctypes
python33_dll = ctypes.CDLL('python33.dll')
a_float = python33_dll.PyFloat_FromDouble(ctypes.c_float(2.0))
python33_dll.PyFloat_Check(a_float)
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    python33_dll.PyFloat_Check(a_float)
  File "C:\Python33\lib\ctypes\__init__.py", line 366, in __getattr__
    func = self.__getitem__(name)
  File "C:\Python33\lib\ctypes\__init__.py", line 371, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'PyFloat_Check' not found

Is there anything specific I need to do to use this function, or is it a bug?

docs.python.org/3.3/c-api/float.html?highlight=double#PyFloat_Check

Was it helpful?

Solution

PyFloat_Check() is a macro. You will need to expand it manually and call the correct function instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top