B ´ÜªLnô†ã @sddlmZddlmZddlmZmZmZddlmZddl m Z ddl Z ddl m Z ddl mZmZddlZddlZddlZddlZd d d d d ddddg ZeefZdZdddddddgZdZdZGdd „d eƒZGdd „d eƒZGdd „d eƒZGdd„deƒZ ydd l!m"Z"Wne#k r.dZ"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-Z0d.Z1d/Z2d0Z3d1Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9ZdZAd?ZBd@ZCdAZDdBZEdCZFdDZGdEZHdFZIdGZJdHZKdIZLdJZMdKZNdLZOdMZPdNZQdOZRdPZSdQZTdRZUdSZVdTZWdUZXdVZYdWZZeJeTeUeVgZ[dXZ\dYZ]dZZ^d[Z_d\Z`d]Zad^Zbd_Zcd`ZddaZedbZfdcZge hddde„eiƒDƒ¡Gdfdg„dgƒZjGdhdi„diƒZkdjdk„Zldldm„Zmdndo„Zndpdq„ZoGdrds„dsƒZpGdtdu„duƒZqd•dvdwœdxdy„Zrd–dvdwœdzd{„Zsdvd|d}d~œdd€„Ztdvd|d}d~œdd‚„Zuy0ddƒlvmZmZmZmwZwmxZxmyZymzZzm{Z{m|Z|Wn4e#k r^epeqZwZxereseteuf\ZyZzZ{Z|YnXd„d…„Z}e~d†krddlZej€d‡dˆZej‚d‰e ƒdŠ¡d‹dŒdej‚dŽddd‘d’ej‚d“dd”d’e „¡Z…e…j†rØe}ƒn>e…j‡sêe ˆ¡n,ddl‰Z‰x"e…j‡D]ZŠe{eŠƒZ‹e‰ ‰e‹¡qúWdS)—é)Ú FunctionType)Údispatch_table)Ú_extension_registryÚ_inverted_registryÚ_extension_cache)Úislice)ÚpartialN)Úmaxsize)ÚpackÚunpackÚ PickleErrorÚ PicklingErrorÚUnpicklingErrorÚPicklerÚ UnpicklerÚdumpÚdumpsÚloadÚloadsz4.0z1.0z1.1z1.2z1.3z2.0z3.0ééc@s eZdZdS)r N)Ú__name__Ú __module__Ú __qualname__©rrú)/opt/alt/python37/lib/python3.7/pickle.pyr @sc@s eZdZdS)r N)rrrrrrrr Dsc@s eZdZdS)rN)rrrrrrrrKs c@seZdZdd„ZdS)Ú_StopcCs ||_dS)N)Úvalue)ÚselfrrrrÚ__init__Ysz_Stop.__init__N)rrrrrrrrrXsr)Ú PyStringMapó(ó.ó0ó1ó2óFóIóJóKóLóMóNóPóQóRóSóTóUóVóXóaóbócódó}óeógóhóiójóló]óoópóqórósótó)óuóGsI01 sI00 ó€óó‚óƒó„ó…ó†ó‡óˆó‰óŠó‹óBóCóŒóóŽóóó‘ó’ó“ó”ó•cCsg|]}t d|¡r|‘qS)z[A-Z][A-Z0-9_]+$)ÚreÚmatch)Ú.0Úxrrrú µsrfc@sFeZdZdZdZdd„Zdd„Zdd„Zdd d „Zd d „Z dd„Z dS)Ú_FramerricCs||_d|_dS)N)Ú file_writeÚ current_frame)rrhrrrr½sz_Framer.__init__cCst ¡|_dS)N)ÚioÚBytesIOri)rrrrÚ start_framingÁsz_Framer.start_framingcCs*|jr&|j ¡dkr&|jddd|_dS)NrT)Úforce)riÚtellÚ commit_frame)rrrrÚ end_framingÄs z_Framer.end_framingFcCsf|jrb|j}| ¡|jks|rb| ¡}|j}t|ƒ|jkrP|ttdt|ƒƒƒ||ƒt   ¡|_dS)Nzz&Can't get local attribute {!r} on {!r}z Can't get attribute {!r} on {!r})ÚsplitÚAttributeErrorÚformatÚgetattr)ÚobjÚnameZsubpathÚparentrrrÚ _getattribute!s rŽc Cszt|ddƒ}|dk r|Sx\ttj ¡ƒD]J\}}|dks(|dkrBq(yt||ƒd|krZ|SWq(tk rpYq(Xq(WdS)NrÚ__main__r)rŠÚlistÚsysÚmodulesÚitemsrŽrˆ)r‹rŒÚ module_nameÚmodulerrrÚ whichmodule.s  r–cCsh|dkr dS| ¡d?d}|j|ddd}|dkrd|dkrd|dd krd|d d @dkrd|dd…}|S) NrrƒréÚlittleT)Ú byteorderÚsignedr€éÿéþÿÿÿé€)Ú bit_lengthÚto_bytes)reÚnbytesÚresultrrrÚ encode_long?s r¢cCstj|dddS)Nr˜T)r™rš)ÚintÚ from_bytes)rwrrrÚ decode_long]sr¥c@sheZdZd7ddœdd„Zdd„Zdd „Zd d „Zd d „Zdd„Zd8dd„Z dd„Z dd„Z d9dd„Z iZ dd„Zee edƒ<dd„Zee e<dd„Zee e<dd„Zee e<d d!„Zee e<d"d#„Zee e<d$d%„Zee e<d&d'„Zee e<d(Zd)d*„Zd+d,„Z e e e!<e"dk re e e"<d-d.„Z#d/d0„Z$e$e e%<d1d2„Z&e&e e'<d:d3d4„Z(d5d6„Z)e(e e*<e)e e<dS);Ú_PicklerNT)Ú fix_importscCs¸|dkr t}|dkrt}n"d|kr.tksy | tt|ƒ d¡d¡Wntk r\tdƒ‚YnXdS)NF)rÜrÂrÃz2persistent IDs in protocol 0 must be ASCII strings) r±r»rxÚ BINPERSIDÚPERSIDrÙrÉÚUnicodeEncodeErrorr )rrÝrrrrÓ+s  z_Pickler.save_persc Cst|tƒstdƒ‚t|ƒs"tdƒ‚|j}|j}t|ddƒ} |jdkrè| dkrè|\} }} t| dƒsntd  | ¡ƒ‚|dk rŽ| |j k rŽtd   | ¡ƒ‚|jd krº|| ƒ||ƒ|| ƒ|t ƒn,t | j | f|ž| Ž}||ƒ|d ƒ|tƒnŽ|jdkr^| d kr^|d } t| dƒstdƒ‚|dk r8| |j k r8tdƒ‚|dd…}|| ƒ||ƒ|tƒn||ƒ||ƒ|tƒ|dk r¼t|ƒ|jkr²|t| |jt|ƒd ¡ƒn | |¡|dk rÐ| |¡|dk rä| |¡|dk rþ||ƒ|tƒdS)Nz'args from save_reduce() must be a tuplez(func from save_reduce() must be callablerÚr·Ú __newobj_ex__Ú__new__z#args[0] from {} args has no __new__z(args[0] from {} args has the wrong classrrÚ __newobj__rz+args[0] from __newobj__ args has no __new__z0args[0] from __newobj__ args has the wrong classr—)rØrÚr Úcallabler»rxrŠr°r¸r‰r¹Ú NEWOBJ_EXrrçÚREDUCEÚNEWOBJr¾r¯ÚPOPrÎrÀÚ_batch_appendsÚ_batch_setitemsÚBUILD) rÚfuncÚargsÚstateZ listitemsZ dictitemsr‹r»rxZ func_nameÚclsÚkwargsrrrrÛ7sd           "      z_Pickler.save_reducecCs| t¡dS)N)rxÚNONE)rr‹rrrÚ save_nonesz_Pickler.save_nonecCs4|jdkr| |rtnt¡n| |r*tnt¡dS)Nr·)r°rxÚNEWTRUEÚNEWFALSEÚTRUEÚFALSE)rr‹rrrÚ save_bool¡s z_Pickler.save_boolcCs.|jr~|dkrN|dkr.| ttd|ƒ¡dS|dkrN| ttd|ƒ¡dSd|krbdkr~nn| ttd|ƒ¡dS|jd krÖt|ƒ}t|ƒ}|d krº| t td|ƒ|¡n| t td|ƒ|¡dSd|krìdkrnn| t t |ƒ  d ¡d ¡n| tt |ƒ  d ¡d ¡dS)Nrr›zdrÂrÃ)r±rxÚBINFLOATr ÚFLOATrÈrÉ)rr‹rrrÚ save_floatÇsz_Pickler.save_floatcCsÞ|jdkr@|s |jtd|dn|jtjt|dƒdf|ddSt|ƒ}|dkrj| tt d|ƒ|¡nf|dkr”|jdkr”|  t t d |ƒ|¡n<||j j kr¸|  tt d |ƒ|¡n| tt d |ƒ|¡| |¡dS) Nrr)r‹Úlatin1r›zdSq>WdS)Nr—r) r»rxr±ÚAPPENDÚiterrrÚ _BATCHSIZErsrÚAPPENDS)rr“r»rxreÚitÚtmprrrrrî9s*       z_Pickler._batch_appendscCs<|jr| t¡n| tt¡| |¡| | ¡¡dS)N)r±rxÚ EMPTY_DICTrÚDICTrÀrïr“)rr‹rrrÚ save_dictTs   z_Pickler.save_dictc CsÜ|j}|j}|js@x(|D] \}}||ƒ||ƒ|tƒqWdSt|ƒ}xŽtt||jƒƒ}t|ƒ}|dkrž|t ƒx |D]\}}||ƒ||ƒqxW|t ƒn(|rÆ|d\}}||ƒ||ƒ|tƒ||jkrJdSqJWdS)Nr—r) r»rxr±ÚSETITEMr&rrr'rsrÚSETITEMS) rr“r»rxÚkÚvr)r*rrrrrïas2     z_Pickler._batch_setitemscCs¨|j}|j}|jdkr0|jtt|ƒf|ddS|tƒ| |¡t|ƒ}xXtt ||j ƒƒ}t |ƒ}|dkr’|t ƒx|D] }||ƒqzW|t ƒ||j krLdSqLWdS)Nr)r‹r)r»rxr°rÛÚsetrÚ EMPTY_SETrÀr&rr'rsrÚADDITEMS)rr‹r»rxr)ZbatchrÚitemrrrÚsave_set€s$     z_Pickler.save_setcCs–|j}|j}|jdkr0|jtt|ƒf|ddS|tƒx|D] }||ƒq>Wt|ƒ|jkr€|t |  |jt|ƒd¡ƒdS|t ƒ|  |¡dS)Nr)r‹r) r»rxr°rÛÚ frozensetrrr¾r¯r rÎÚ FROZENSETrÀ)rr‹r»rxr5rrrÚsave_frozenset˜s    z_Pickler.save_frozensetc CsX|j}|j}|dkr t|ddƒ}|dkr.|j}t||ƒ}y(t|ddtj|}t||ƒ\}}Wn.t t t fk rŽt d|||fƒd‚YnX||k rªt d|||fƒ‚|j dkrt ||f¡} | r| dkræ|ttd| ƒƒn0| d kr|ttd | ƒƒn|ttd | ƒƒdS| d ¡d} ||kr6| }|j d kr`| |¡| |¡|tƒnê||k r|| t|| f¡nÎ|j dkr®|tt|dƒdt|dƒdƒnœ|jrôtj} tj} ||f| krâ| ||f\}}n|| krô| |}y(|tt|dƒdt|dƒdƒWn,tk rHt d|||j fƒd‚YnX| |¡dS)Nrr)Úlevelz(Can't pickle %r: it's not found as %s.%sz2Can't pickle %r: it's not the same object as %s.%sr·r›zd?„Z7e7ee8d<d@dA„Z9e9ee:d<dBdC„Z;e;eed<dFdG„Z?e?ee@d<dHdI„ZAeAeeBd<dJdK„ZCeCeeDd<dLdM„ZEeEeeFd<dNdO„ZGeGeeHd<dPdQ„ZIeIeeJd<dRdS„ZKeKeeLd<dTdU„ZMeMeeNd<dVdW„ZOeOeePd<dXdY„ZQeQeeRd<dZd[„ZSd\d]„ZTeTeeUd<d^d_„ZVeVeeWd<d`da„ZXeXeeYd<dbdc„ZZeZee[d<ddde„Z\e\ee]d<dfdg„Z^e^ee_d<dhdi„Z`e`eead<djdk„Zbebeecd<dldm„Zdedeeed<dndo„Zfdpdq„Zgdrds„Zheheeid<dtdu„Zjejeekd<dvdw„Zleleemd<dxdy„Zneneeod<dzd{„Zpepeeqd<d|d}„Zrereesd<d~d„Zteteeud<d€d„Zveveewd<d‚dƒ„Zxexeeyd<d„d…„Zzezee{d<d†d‡„Z|e|ee}d<dˆd‰„Z~e~eed<dŠd‹„Z€e€eed<dŒd„Z‚e‚eeƒd<dŽd„Z„e„ee…d<dd‘„Z†e†ee‡d<d’d“„Zˆeˆee‰d<d”d•„ZŠeŠee‹d<d–d—„ZŒeŒeed<d˜S)™Ú _UnpicklerTÚASCIIÚstrict)r§ÚencodingÚerrorscCs2|j|_|j|_i|_||_||_d|_||_dS)Nr) r‚Ú_file_readliner~Ú _file_readr¯rNrOr°r§)rr³r§rNrOrrrrsz_Unpickler.__init__c Cs¼t|dƒstd|jjfƒ‚t|j|jƒ|_|jj|_|jj |_ g|_ g|_ |j j |_ d|_ |j}|j}y*x$|dƒ}|s|t‚||d|ƒqlWWn$tk r¶}z|jSd}~XYnXdS)NrQz4Unpickler.__init__() was not called by %s.__init__()rr—)r¸rr¹rr{rQrPÚ _unframerr~r‚Ú metastackÚstackÚappendr°rÕÚEOFErrorrr)rr~rÕÚkeyZstopinstrrrr's(    z_Unpickler.loadcCs |j}|j ¡|_|jj|_|S)N)rTrSÚpoprU)rr“rrrÚpop_markEs  z_Unpickler.pop_markcCs tdƒ‚dS)Nz%unsupported persistent id encountered)r)rrÝrrrÚpersistent_loadKsz_Unpickler.persistent_loadcCs:| d¡d}d|kr"tks0ntd|ƒ‚||_dS)Nr—rzunsupported pickle protocol: %d)r~r©rªr°)rr°rrrÚ load_protoPs z_Unpickler.load_protorcCs8td| d¡ƒ\}|tjkr(td|ƒ‚|j |¡dS)Nz sys.maxsize: %d)r r~r‘r rªrRr…)rr„rrrr…Ws  z_Unpickler.load_framecCsLy| ¡dd… d¡}Wntk r6tdƒ‚YnX| | |¡¡dS)Nr€rÂz2persistent IDs in protocol 0 must be ASCII strings)r‚ÚdecodeÚUnicodeDecodeErrorrrUrZ)rrÝrrrÚ load_persid^s  z_Unpickler.load_persidcCs|j ¡}| | |¡¡dS)N)rTrXrUrZ)rrÝrrrÚload_binpersidgs z_Unpickler.load_binpersidcCs| d¡dS)N)rU)rrrrÚ load_nonelsz_Unpickler.load_nonecCs| d¡dS)NF)rU)rrrrÚ load_falsepsz_Unpickler.load_falsecCs| d¡dS)NT)rU)rrrrÚ load_truetsz_Unpickler.load_truecCsL| ¡}|tdd…krd}n |tdd…kr4d}n t|dƒ}| |¡dS)Nr—FTr)r‚rûrúr£rU)rrwÚvalrrrÚload_intxs z_Unpickler.load_intcCs| td| d¡ƒd¡dS)Nztd| d¡ƒ\}|dkr"tdƒ‚| |¡}| t|ƒ¡dS)Nzdr\r)rUr r~)rrrrÚ load_binfloat©sz_Unpickler.load_binfloatcCs"|jdkr|S| |j|j¡SdS)Nr )rNr]rO)rrrrrÚ_decode_string­s z_Unpickler._decode_stringcCsl| ¡dd…}t|ƒdkrF|d|dkrF|ddkrF|dd…}ntdƒ‚| | t |¡d¡¡dS)Nr€r·rs"'r—z)the STRING opcode argument must be quoted)r‚rsrrUror Ú escape_decode)rrwrrrÚ load_string¶s (z_Unpickler.load_stringcCs@td| d¡ƒ\}|dkr"tdƒ‚| |¡}| | |¡¡dS)Nz*sz(_Unpickler.load_dict..rr·)rYÚrangersrU)rÚdr)r“rÚ load_dict(s z_Unpickler.load_dictc Cs‚|st|tƒrt|dƒrjy ||Ž}Wqttk rf}z$td|jt|ƒft ¡dƒ‚Wdd}~XYqtXn | |¡}|  |¡dS)NZ__getinitargs__zin constructor for %s: %sr·) rØrÔr¸r¬rrÙr‘Úexc_inforçrU)rÚklassròrÚerrrrrÚ _instantiate4s  0 z_Unpickler._instantiatecCsL| ¡dd… d¡}| ¡dd… d¡}| ||¡}| || ¡¡dS)Nr€rÂ)r‚r]Ú find_classrrY)rr•rŒr‹rrrÚ load_inst@s z_Unpickler.load_instcCs"| ¡}| d¡}| ||¡dS)Nr)rYrXr)rròrôrrrÚload_objGs z_Unpickler.load_objcCs2|j ¡}|j ¡}|j|f|žŽ}| |¡dS)N)rTrXrçrU)rròrôr‹rrrÚ load_newobjNs  z_Unpickler.load_newobjcCs>|j ¡}|j ¡}|j ¡}|j|f|ž|Ž}| |¡dS)N)rTrXrçrU)rrõròrôr‹rrrÚload_newobj_exUs    z_Unpickler.load_newobj_excCsF| ¡dd… d¡}| ¡dd… d¡}| ||¡}| |¡dS)Nr€zutf-8)r‚r]rŽrU)rr•rŒr‹rrrÚ load_global]s z_Unpickler.load_globalcCsJ|j ¡}|j ¡}t|ƒtk s,t|ƒtk r4tdƒ‚| | ||¡¡dS)NzSTACK_GLOBAL requires str)rTrXrÔrÙrrUrŽ)rrŒr•rrrÚload_stack_globalds   z_Unpickler.load_stack_globalcCs| d¡d}| |¡dS)Nr—r)r~Ú get_extension)rrErrrÚ load_ext1lsz_Unpickler.load_ext1cCs td| d¡ƒ\}| |¡dS)Nzr—r?r˜r@r•rŽr™rëršrír›r rœÚDUPrrÌržrÊrŸrËr rÇr¡rÅr¢rÆr£rÄr¤r%r¦r(r§r.r¨r/r«r4r²rðr³rr´r¼rrrrrKs$                                                                   rKT)r§cCst|||d |¡dS)N)r§)r¦r)r‹r³r´r§rrrÚ_dump0sr¾cCs(t ¡}t|||d |¡| ¡}|S)N)r§)rjrkr¦rÚgetvalue)r‹r´r§rvZresrrrÚ_dumps3srÀrLrM)r§rNrOcCst||||d ¡S)N)r§rNrO)rKr)r³r§rNrOrrrÚ_load:srÁcCs0t|tƒrtdƒ‚t |¡}t||||d ¡S)Nz%Can't load pickle from unicode string)r§rNrO)rØrÙr¬rjrkrKr)Úsr§rNrOr³rrrÚ_loads>s   rÃ) r r rrrrrrrcCsddl}| ¡S)Nr)ÚdoctestZtestmod)rÄrrrÚ_testWsrÅrz$display contents of the pickle files)Ú descriptionÚ pickle_fileÚbrÚ*zthe pickle file)rÔÚnargsÚhelpz-tz--testÚ store_truezrun self-test suite)ÚactionrËz-vz)run verbosely; only affects self-test run)N)N)ŒÚtypesrÚcopyregrrrrÚ itertoolsrÚ functoolsrr‘r Ústructr r rbrjr rDÚ__all__r Ú bytearrayZ bytes_typesZformat_versionZcompatible_formatsr©r¨Ú Exceptionr r rrZorg.python.corer r<rr¼rír r½rrrÿrýrrþrörãrârërµr¶r·rrr%rðrCr,r+r(rÌrÊr»rËr#r"r¼rÇrÅrÆr.rrr/rrúrûrºrìr>r?r@r¸r¹rºrørùrrrrr rrr r3r4r8rêrBrÄrur¥Údirrgr{rŽr–r¢r¥r¦rKr¾rÀrÁrÃÚ_picklerrrrrrrÅrÚargparseÚArgumentParserÚparserÚ add_argumentÚFileTypeÚ parse_argsròZtestrÇÚ print_helpZpprintrvr‹rrrrÚs,        ?* 40