Use the ZODB.serializer.ObjectReader to handle all the edge cases.