bpo-1635741: pyexpat error handling by koubaa · Pull Request #22489 · python/cpython

LGTM, but please address the few minor remaining issues before I can merge your change.

Oh wow, I didn't expect a so large PR to add error handling to PyInit_pyexpat()! Maybe there was a reason to ignore errors :-D It's complex to handle errors in C :-(

I like the new design of the code with many smaller functions and more narrow scope for variables. It's way simpler to track the lifetime of each variable, and so check manually for reference leaks!

Note: I still hate the INCREF/DECREF required by PyModule_AddObject() (that's unrelated to your PR, I just hate this function.)