memory allocation failure Replace also PyMem_Free() with PyMem_FREE() to be consistent with the rest of the function.