<p></p>
<p dir="auto">Just compile the old code! You get a ton of warnings that PyErr_SetString "returns" <code class="notranslate">void</code>.</p>
<p dir="auto">Python has, at heart, a very simple API. A C function <strong>either</strong> returns an object <strong>or</strong> it sets an exception (and returns NULL). Never both! (Or None for that matter.)</p>
<p dir="auto">PyNone is a regular Python object. NULL is not, it's the API's marker for raising an exception.</p>
<p dir="auto">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.</p>
<p dir="auto">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.</p>
<p dir="auto"><a href="https://docs.python.org/3/c-api/exceptions.html" rel="nofollow">https://docs.python.org/3/c-api/exceptions.html</a></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/3231#issuecomment-1235599065">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZKLJXYSDVZDU5UHXTDV4IIJDANCNFSM6AAAAAAQDEVUYM">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZI7PIP45ML7RR63SDLV4IIJDA5CNFSM6AAAAAAQDEVUYOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSJUW7NS.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/pull/3231/c1235599065</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/3231#issuecomment-1235599065",
"url": "https://github.com/kamailio/kamailio/pull/3231#issuecomment-1235599065",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>