[@sdZddlmZddlmZddlmZmZmZddlm Z ddl Z ddl m Z ddl m Z mZddlZddlZddlZddlZd d d d d ddddg ZeefZdZdddddddgZdZdZGdd d eZGdd d eZGdd d eZGdddeZydd l m!Z!Wne"k rdZ!YnXd!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7d6Z8d7Z9d8Z:d9Z;d:Z<d;Z=d<Z>d=Z?d>Z@d?ZAd@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIdHZJdIZKdJZLdKZMdLZNdMZOdNZPdOZQdPZRdQZSdRZTdSZUdTZVdUZWdVZXdWZYeIeSeTeUgZZdXZ[dYZ\dZZ]d[Z^d\Z_d]Z`d^Zad_Zbd`ZcdaZddbZedcZfejgdddeehDGdfdgdgZiGdhdidiZjdjdkdlZkdjdmdnZldodpZmdqdrZnGdsdtdtZoGdudvdvZpddwdxdydzZqddwdxd{d|Zrdwdxd}d~ddddZsdwdxd}d~ddddZtyDddlumZmZmZmvZvmwZwmxZxmyZymzZzm{Z{WnBe"k reoepf\ZvZweqeresetf\ZxZyZzZ{YnXddZ|e}dkrddl~Z~e~jddZejdde~jdddddejddddddejdddddejZejrye|nPej rejn9ddlZx*ejD]ZezeZejeqWndS)aCreate portable serialized representations of Python objects. See module copyreg for a mechanism for registering custom picklers. See module pickletools source for extensive comments. Classes: Pickler Unpickler Functions: dump(object, file) dumps(object) -> string load(file) -> object loads(string) -> object Misc variables: __version__ format_version compatible_formats ) FunctionType)dispatch_table)_extension_registry_inverted_registry_extension_cache)isliceN)maxsize)packunpack PickleError PicklingErrorUnpicklingErrorPickler Unpicklerdumpdumpsloadloadsz4.0z1.0z1.1z1.2z1.3z2.0z3.0c@seZdZdZdS)r z6A common base class for the other pickling exceptions.N)__name__ __module__ __qualname____doc__rr/usr/lib/python3.4/pickle.pyr ?s c@seZdZdZdS)r z]This exception is raised when an unpicklable object is passed to the dump() method. N)rrrrrrrrr Cs c@seZdZdZdS)r aThis exception is raised when there is a problem unpickling an object, such as a security violation. Note that other exceptions may also be raised during unpickling, including (but not necessarily limited to) AttributeError, EOFError, ImportError, and IndexError. N)rrrrrrrrr Js c@seZdZddZdS)_StopcCs ||_dS)N)value)selfrrrr__init__Xsz_Stop.__init__N)rrrrrrrrrWs r) PyStringMap(.012FIJKLMNPQRSTUVXabcd}eghijl]opqrst)uGsI01 sI00 ssssssssssssBCsssssssssscCs(g|]}tjd|r|qS)z[A-Z][A-Z0-9_]+$)rematch).0xrrr s rPc@sUeZdZdZddZddZddZd d d Zd d ZdS)_Framer@icCs||_d|_dS)N) file_write current_frame)rrSrrrrs z_Framer.__init__cCstj|_dS)N)ioBytesIOrT)rrrr start_framingsz_Framer.start_framingcCs>|jr:|jjdkr:|jddd|_ndS)NrforceT)rTtell commit_frame)rrrr end_framingsz_Framer.end_framingFc Cs|jr|j}|j|jks-|r|jC}t|}|j}|t|td|||WdQX|jd|j qndS)Nz= 4 to enable supportzz&Can't get local attribute {!r} on {!r}z Can't get attribute {!r} on {!r})splitr^AttributeErrorformatgetattr)objnameallow_qualnameZ dotted_pathZsubpathrrr _getattributes     ryc Cst|dd}|dk r"|SxvttjjD]_\}}|dks8|dkrbq8ny t||||kr|SWq8tk rYq8Xq8WdS)z$Find the module an object belong to.rN__main__)rulistsysmodulesitemsryrs)rvrwrx module_namemodulerrr whichmodules "  rcCs|dkrdS|jd?d}|j|dddd}|dkr|dkr|d d kr|dd @dkr|d d}qn|S)aEncode a long to a two's complement little-endian binary string. Note that 0 is a special case, returning an empty string, to save a byte in the LONG1 pickling context. >>> encode_long(0) b'' >>> encode_long(255) b'\xff\x00' >>> encode_long(32767) b'\xff\x7f' >>> encode_long(-256) b'\x00\xff' >>> encode_long(-32768) b'\x00\x80' >>> encode_long(-128) b'\x80' >>> encode_long(127) b'\x7f' >>> rrnrrj byteorderlittlesignedTNrkrk) bit_lengthto_bytes)rOnbytesresultrrr encode_long's $rcCstj|ddddS)a\Decode a long from a two's complement little-endian binary string. >>> decode_long(b'') 0 >>> decode_long(b"\xff\x00") 255 >>> decode_long(b"\xff\x7f") 32767 >>> decode_long(b"\x00\xff") -256 >>> decode_long(b"\x00\x80") -32768 >>> decode_long(b"\x80") -128 >>> decode_long(b"\x7f") 127 rrrT)int from_bytes)rcrrr decode_longEsrc@seZdZdddddZddZdd Zd d Zd d ZddZdddZ ddZ ddZ ddddddZ iZ ddZee eddrs )rreBINFLOATr FLOATrr)rrvrrr save_floats z_Pickler.save_floatcCs|jdkrZ|s.|jtfd|n(|jtjt|ddfd|dSt|}|dkr|jtt d||nZ|dkr|jdkr|jt t d||n|jt t d |||j |dS) Nrrvlatin1rzd?Z5e5ee6dd sys.maxsize: %d)r rir|rrr7rp)rrorrrrp-sz_Unpickler.load_framecCs9|jddjd}|j|j|dS)Nrjrrk)rmdecoder;r@)rrrrr load_persid4sz_Unpickler.load_persidcCs)|jj}|j|j|dS)N)r:popr;r@)rrrrrload_binpersid9sz_Unpickler.load_binpersidcCs|jddS)N)r;)rrrr load_none>sz_Unpickler.load_nonecCs|jddS)NF)r;)rrrr load_falseBsz_Unpickler.load_falsecCs|jddS)NT)r;)rrrr load_trueFsz_Unpickler.load_truecCsj|j}|tddkr+d}n.|tddkrJd}nt|d}|j|dS)NrjFTr)rmrrrr;)rrcvalrrrload_intJs   z_Unpickler.load_intcCs'|jtd|jdddS)NzdrBr)r;r ri)rrrr load_binfloat{sz_Unpickler.load_binfloatcCs-|jdkr|S|j|j|jSdS)Nr)r1rCr3)rrrrr_decode_stringsz_Unpickler._decode_stringcCs|jdd}t|dkr_|d|dkr_|ddkr_|dd}n td|j|jtj|ddS) Nrjrrs"'z)the STRING opcode argument must be quotedrkrkrk)rmr^r r;rUr escape_decode)rrcrrr load_strings 6 z_Unpickler.load_stringcCs_td|jd\}|dkr6tdn|j|}|j|j|dS)Nzs z(_Unpickler.load_dict..rr)r?r:ranger^)rrdr)r~r load_dicts  z_Unpickler.load_dictcCst|j|dd}|j|d=|sRt|t sRt|dry||}Wqtk r}z1td|jt|ftj dWYdd}~XqXn|j |}|j |dS)NrjZ__getinitargs__zin constructor for %s: %sr) rr:rrrrrrr|exc_inforr;)rklassrrrerrrrr _instantiates<z_Unpickler._instantiatecCsj|jddjd}|jddjd}|j||}|j||jdS)Nrjrrkrk)rmrC find_classrrr?)rrrwrprrr load_inst sz_Unpickler.load_instcCs6|j}|jj|d}|j||dS)Nrj)r?r:rErr)rrrprrrload_objs z_Unpickler.load_objcCsA|jj}|jj}|j||}|j|dS)N)r:rErr;)rrrrvrrr load_newobjsz_Unpickler.load_newobjcCsS|jj}|jj}|jj}|j|||}|j|dS)N)r:rErr;)rrrrrvrrrload_newobj_ex"s z_Unpickler.load_newobj_excCsa|jddjd}|jddjd}|j||}|j|dS)Nrjzutf-8rkrk)rmrCrsr;)rrrwrprrr load_global*sz_Unpickler.load_globalcCsn|jj}|jj}t|tk sBt|tk rQtdn|j|j||dS)NzSTACK_GLOBAL requires str)r:rErrr r;rs)rrwrrrrload_stack_global1s $z_Unpickler.load_stack_globalcCs$|jdd}|j|dS)Nrjr)ri get_extension)rr*rrr load_ext19sz_Unpickler.load_ext1cCs,td|jd\}|j|dS)Nzsz_Unpickler.load_ext2cCs,td|jd\}|j|dS)NzrrrrzHs    z_Unpickler.get_extensioncCs|jdkrk|jrk||ftjkrItj||f\}}n|tjkrktj|}qknt|ddttj||d|jdkS)Nrrrrxr) rrr(Z NAME_MAPPINGZIMPORT_MAPPINGr ryr|r})rrrwrrrrsXsz_Unpickler.find_classc Csh|j}|j}|d}y||}Wn(ttjt||YnX||dr/rrr load_setitems     z_Unpickler.load_setitemcCsq|j}|j}||d}x:t|dt|dD]}||d|||s"           $*  t3D #