The MemoryError
is being raised in an out of memory situations, as per the docs.
Is there any chance your code is looping there indefinitely?
Or you may actually be hitting the memory limit on a 32-bit version of Python just because of concatenating too much data, a similar situation as described here. In that case, you might be able to optimize the concatenation or use a 64-bit version of Python to get you through.