[Python-Dev] Adding insint() function

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Fri, 18 Aug 2000 20:17:53 +0200 (CEST)


Andrew Kuchling wrote:
> 
> On Fri, Aug 18, 2000 at 01:52:20PM -0400, Tim Peters wrote:
> >+1, provided the treatment of errors is clearly documented.
> 
> The treatment of errors in module init functions seems to be simply
> charge ahead and do the inserts, and then do 'if (PyErr_Occurred())
> Py_FatalError())'.  The new function will probably return NULL if
> there's an error, but I doubt anyone will check it; it's too ungainly
> to write 
>   if ( (PyDict_SetItemStringInt(d, "foo", FOO)) == NULL ||
>        (PyDict_SetItemStringInt(d, "bar", BAR)) == NULL || 
>        ... repeat for 187 more constants ...

:-)

So name it PyModule_AddConstant(module, name, constant),
which fails with "can't add constant to module" err msg.

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252