#A* ------------------------------------------------------------------- #B* This file contains source code for the PyMOL computer program #C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific. #D* ------------------------------------------------------------------- #E* It is unlawful to modify or remove this copyright notice. #F* ------------------------------------------------------------------- #G* Please see the accompanying LICENSE file for further information. #H* ------------------------------------------------------------------- #I* Additional authors of this source file include: #-* #-* #-* #Z* ------------------------------------------------------------------- from chempy import Storage if True: import pickle # Python 3: Unpickle printable ASCII strings in [TAB, DEL) to unicode, # and everything else to bytes. # This uses the Python implementation of pickle, not the fast cpython # version, which unfortunately is much slower. def _decode_string(self, value): if all(8 < b < 127 for b in value): return value.decode('ascii') return value pickle._Unpickler._decode_string = _decode_string # string pickling backported from Python 2 def save_str(self, obj): from struct import pack if self.bin: if not isinstance(obj, bytes): obj = obj.encode('utf-8', 'ignore') n = len(obj) if n < 256: self.write(pickle.SHORT_BINSTRING + pack("