def _read_state(self, idx):
            '''Reads a state from the undo buffer by unpickling it from the temporary file at position idx.
            Rewinds the file to the beginning for future reads before returning the object'''
            if os.environ.get('ENABLE_UNDO_TEMPFILES', '0') == '1':
                obj = pickle.load(self.undoList[idx])
                self.undoList[idx].seek(0)
                return obj
            else:
                return pickle.loads(self.undoList[idx])
Reads a state from the undo buffer by unpickling it from the temporary file at position idx.
            Rewinds the file to the beginning for future reads before returning the object
durdraw/durdraw_undo.py