def improve_memory_error_message(error, msg=''):
 assert isinstance(error, MemoryError)
 if str(error):
  raise error
 else:
  raise TypicalMemoryError(msg)

def improve_memory_error_message ( error , msg = '' ) : assert isinstance ( error , MemoryError ) if str ( error ) : raise error else : raise TypicalMemoryError ( msg )
raises a typicalmemoryerror if the memoryerror has no messages parameters error: memoryerror an instance of memoryerror msg: string a message explaining what possibly happened .