Just compile the old code! You get a ton of warnings that PyErr_SetString "returns" void.

Python has, at heart, a very simple API. A C function either returns an object or it sets an exception (and returns NULL). Never both! (Or None for that matter.)

PyNone is a regular Python object. NULL is not, it's the API's marker for raising an exception.

Thus, the old code works perfectly well as long as it doesn't raise an exception. If/when it does, depending on the whims of the C compiler, the return value for the old version might be anything whatsoever. Even NULL if you're lucky.

Python has a ton of somewhat-higher-level error-generating functions which explicitly return NULL so that you can use the old construct but sadly PyErr_SetString is not one of these.

https://docs.python.org/3/c-api/exceptions.html


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <kamailio/kamailio/pull/3231/c1235599065@github.com>