Issue 20228: Argument Clinic should understand Python special methods (original) (raw)
As per Georg's request (and hacks in other places), Argument Clinic should have support for special methods. To wit:
init should be required to be an instance method. Clinic should suppress its methoddef #define.
new should be required to be a class method. Its C function name should have the new stripped off, and by convention its first argument should be "PyTypeObject *type". Clinic should suppress its methoddef #define.
All other dunder-methods which have special slots in the PyTypeObject structure should be rejected by Argument Clinic. (Their arguments are pre-parsed, and they don't have docstrings... what would Clinic do for them?) Obviously generic dunder-methods ("getstate", "sizeof") are still fine.