CLN validate some Py_* Functions in C Extensions check for NULL
xref #49756

@WillAyd is this what you had in mind?

In cases like

https://github.com/pandas-dev/pandas/blob/3a1a8b3c6bc94a3036e45d75adf33adc5b35c697/pandas/_libs/src/ujson/python/objToJSON.c#L902-L906

which return `void`, how should `NULL` be handled?
For functions that return `void` your hands are a bit tied. In that particular case `PyObject_Dir` should be setting the global python indicator, so somewhere along the lines you could do a `PyErr_Occurred()` check and see what happened. But that's thorny so I would just ignore for now.

Would be curious how that gets handled upstream in ultrajson. Seems like there's a much more natural way to serialize the built-in types than what we have here This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this. thanks for your review

I probably won't have a chance to update this any time soon due to there being quite a few other tasks to take care of, so closing for now to clear the queue