@classmethod
    def load(cls, filename):
        pickle = _lazy_import_pickle()
        try:
            with open(filename, "rb") as fp:
                data = pickle.load(fp)
        except Exception:
            err = sys.exc_info()[1]
            print("ERROR: Failed to load %s: [%s] %s" % (filename, type(err).__name__, err))
            sys.exit(1)

        try:
            if data['format_version'] != cls.FORMAT_VERSION:
                raise TypeError("unknown format version")

            stats = data['stats']
            timestamp = data['timestamp']
            pid = data['pid']
            process_memory = data.get('process_memory')
            user_data = data.get('user_data')
        except __HOLE__:
            raise TypeError("invalid file format")

        return cls(stats, timestamp, pid, process_memory, user_data)
dataset/ETHPy150Open wyplay/pytracemalloc/tracemalloc.py/Snapshot.load