[Python-Dev] Handle errors in cleanup code