[issue31791] Ensure that all PyTypeObject fields are set to non-NULL defaults

pdox report at bugs.python.org
Sun Oct 15 03:25:24 EDT 2017


pdox <pdox at alum.mit.edu> added the comment:

serhiy.storchaka:

1) Where tp_as_number would normally be NULL, instead it would point to a fixed PyNumberMethods structure containing the default functions. This would make the memory increase negligible, as all non-number types would use the same structure.

2) If this is behavior we want to formally support, then we should provide macros for it. (all they must do is compare against the default pointer value, rather than NULL). Are there particular extension(s) you suspect may be doing this?

3) This has to be handled on a case-by-case basis. I would not remove inlined optimizations. If there are some fields that truly benefit from remaining NULL, those can be left alone. I would like to focus on the functions for which the common case (in code without type errors) is to make the indirect call.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31791>
_______________________________________


More information about the Python-bugs-list mailing list