Dev:2.4/Source/Python/Method Deprecation
Useful ideas.... I've started using this in the Ipo and Curve modules for changes to the API. I think it's a good idea to also use the BLENDER_VERSION (in BLE_blender.h) to be sure the code gets flagged for deletion after deprecation. For example:
/* #####DEPRECATED###### */
#if BLENDER_VERSION < 243
static PyObject *Ipo_getNcurves( BPy_Ipo * self )
{
#if BLENDER_VERSION < 241 static int depcount = 2;
if ( depcount ) {
printf ("Ipo.getNcurves() is deprecated by the len() operator.\n");
printf (" This method will be removed after version 2.40.\n");
depcount--;
}
// body of function here
#else
return EXPP_ReturnPyObjError( PyExc_NotImplementedError,
"replaced by \"len(ipo)\"" );
#endif
}
When the function is called, a deprecation warning is printed (two times max) until version 2.41, when a NotImplemented exception is thrown. After version 2.43, a compile error occurs which forces us to remove the old code.
-- KenHughes - 08 Jul 2005