import codecs
import gc
import ast


def loads(serialized_bytes):
    """Deserialize bytes back to object tree. Uses ast.literal_eval (safe)."""
    serialized = codecs.decode(serialized_bytes, "utf-8")
    if '\x00' in serialized:
        raise ValueError(
            "The serpent data contains 0-bytes so it cannot be parsed by ast.literal_eval. Has it been corrupted?")
    try:
        gc.disable()
        return ast.literal_eval(serialized)
    finally:
        gc.enable()