With the following code that leads to a memory overflow:
import numpy as np
a = np.arange(10000000)
np.save('a', a)
l = []
while True:
l.append(np.load('a.npy'))
Python errors out a Segmentation fault, instead of a MemoryError. It seems to be the case for machines like AWS EC2 which don't have swap memory (I've tried with a machine with more RAM and a swap memory and I get a MemoryError).