[3.7] bpo-36389: _PyObject_IsFreed() now also detects uninitialized memory (GH-12770) by vstinner · Pull Request #12780 · python/cpython

@vstinner

…H-12770)

Rename _PyMem_IsFreed() function to _PyMem_IsPtrFreed(). The function
is now way more efficient, it became a simple comparison on integers,
rather than a short loop. It detects also uninitialized bytes and
"forbidden bytes" filled by debug hooks on memory allocators.

Add unit tests on _PyObject_IsFreed().

(cherry picked from commit 2b00db6)