[Bf-python] Memory leak - BPY

Ken Hughes khughes at pacific.edu
Fri Apr 6 09:46:37 CEST 2007


Campbell Barton wrote:
> Hey Ken,
> 
> I dont see how PyObject_IsTrue relates to PyNumber_Float or PyNumber_Int?

The relation is this: PyObject_IsTrue() will let you say

    ob.selected = True
or
    ob.selected = 1
or anything else which Python would evaluate as True using bool().  The 
gist of the discussion I referred to (as I interpreted it) was to be as 
forgiving of user input as possible (can't remember the expression 
Stephen quoted).  Since the consensus at that time was to go with 
PyObject_IsTrue(), my assumption was we should follow that elsewhere in 
the API.

> With my additions to the python API Iv been using PyFloat_AsDouble and 
> PyNumber_Check seem to work with floats and ints.
> 
> see - boxPack_FromPyObject
> 
> I should do some testing to see exactly what it will and wont accept, 
> (the py docs dont help - http://www.python.org/doc/api/floatObjects.html)

I tried passing strings like '1.2' to PyFloat_AsDouble() and as I 
expected, it doesn't return a float value of 1.2.  Same type of thing 
for PyInt_AsLong().

Ken



More information about the Bf-python mailing list