Adding C API for use in tp_traverse

I’m not convinced these are worth the complexity of adding new functions, but I don’t feel super strongly.

I guess the idea is that they’re not safe if they are called incorrectly and set an exception, but:

  1. Just don’t call them incorrectly. These exceptions are all of the “programmer error” type, not runtime error.

  2. Pretty much nobody checks the exception anyways. They’re useless.

We’ve made our lives more difficult by making these simple functions capable of failing. I think the idea is that validating arguments and raising a Python error is somehow nicer for C API users than a C assertion or fatal error, but that totally ignores how people actually use these APIs.

6 Likes