catching typeerror when pickling