1

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Can you give me any other tip on how to do it?
I dont really know much about C. I would expect that to be a function. Anyway, if I call PyObject_TypeCheck it says it was also not found.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.