bpo-35081: Move Py_BUILD_CORE code to internal/mem.h (GH-10249)

* Add #include "internal/mem.h" to C files using
  _PyMem_SetDefaultAllocator().
* Include/internal/mem.h now requires Py_BUILD_CORE to be defined.
diff --git a/Python/pystate.c b/Python/pystate.c
index d049811..98e954d 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -2,6 +2,7 @@
 /* Thread and interpreter state structures and their interfaces */
 
 #include "Python.h"
+#include "internal/mem.h"
 #include "internal/pystate.h"
 
 #define _PyThreadState_SET(value) \