def custom_serializer(obj, serpent_serializer, outputstream, indentlevel):
    replaced = replacement_function(obj)
    if (replaced is obj):
        serpent_serializer.ser_default_class(replaced, outputstream, indentlevel)
    else:
        serpent_serializer._serialize(replaced, outputstream, indentlevel)
def custom_serializer(obj, serpent_serializer, outputstream, indentlevel):
    replaced = replacement_function(obj)
    if (replaced is obj):
        serpent_serializer.ser_default_class(replaced, outputstream, indentlevel)
    else:
        serpent_serializer._serialize(replaced, outputstream, indentlevel)