Yes, but if some other exception (e.g. SessionExpiredError) is raised, data won't be set. OTOH, in that case the exception isn't handled so putting it back as it was before should be safe..? Putting it in "finally" would cause an exception in that case I think.