AlkantarClanX12

Your IP : 18.218.245.179


Current Path : /lib64/python3.8/__pycache__/
Upload File :
Current File : //lib64/python3.8/__pycache__/pickle.cpython-38.pyc

U

e5d��	@shdZddlmZddlmZddlmZmZmZddlm	Z	ddl
mZddlZddlm
Z
dd	lmZmZddlZddlZddlZddlZd
ddd
dddddg	ZzddlmZe�d�dZWnek
r�dZYnXeefZdZddddddddgZdZ d Z!Gd!d
�d
e"�Z#Gd"d�de#�Z$Gd#d�de#�Z%Gd$d%�d%e"�Z&zdd&l'm(Z(Wnek
�rldZ(YnXd'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@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIdHZJdIZKdJZLdKZMdLZNdMZOdNZPdOZQdPZRdQZSdRZTdSZUdTZVdUZWdVZXdWZYdXZZdYZ[dZZ\d[Z]d\Z^d]Z_eOeYeZe[gZ`d^Zad_Zbd`ZcdaZddbZedcZfddZgdeZhdfZidgZjdhZkdiZldjZmdkZndlZoe�pdmdn�eq�D��Gdodp�dp�ZrGdqdr�dr�Zsdsdt�Ztdudv�Zudwdx�Zvdydz�ZwGd{d|�d|�ZxGd}d~�d~�Zyd�ddd�d�d��Zzd�ddd�d�d��Z{dd�d�dd��d�d��Z|dd�d�dd��d�d��Z}z0dd�lm#Z#m$Z$m%Z%m~Z~mZm�Z�m�Z�m�Z�m�Z�Wn4ek
�r�exeyZ~Zeze{e|e}f\Z�Z�Z�Z�YnXd�d��Z�e�d�k�rdddl�Z�e�j�d�d��Z�e�j�d�e���d��d�d�d��e�j�d�d�d�d�d��e�j�d�d�d�d��e����Z�e�j��r*e��n:e�j��s<e����n(ddl�Z�e�j�D]Z�e�e��Z�e���e���qJdS)�a�Create 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)�islice)�partialN)�maxsize)�pack�unpack�PickleError�
PicklingError�UnpicklingError�Pickler�	Unpickler�dump�dumps�load�loads)�PickleBufferrTFz4.0z1.0z1.1z1.2z1.3z2.0z3.0z5.0��c@seZdZdZdS)rz6A common base class for the other pickling exceptions.N��__name__�
__module__�__qualname__�__doc__�rr�/usr/lib64/python3.8/pickle.pyrIsc@seZdZdZdS)r
z]This exception is raised when an unpicklable object is passed to the
    dump() method.

    Nrrrrrr
Msc@seZdZdZdS)raThis 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.

    NrrrrrrTsc@seZdZdd�ZdS)�_StopcCs
||_dS�N)�value��selfr!rrr�__init__bsz_Stop.__init__N)rrrr$rrrrrasr)�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�
<listcomp>�srnc@sFeZdZdZdZdd�Zdd�Zdd�Zdd
d�Zdd
�Z	dd�Z
dS)�_FramerricCs||_d|_dSr )�
file_write�
current_frame)r#rprrrr$�sz_Framer.__init__cCst��|_dSr )�io�BytesIOrq�r#rrr�
start_framing�sz_Framer.start_framingcCs*|jr&|j��dkr&|jdd�d|_dS)NrT��force)rq�tell�commit_framertrrr�end_framing�sz_Framer.end_framingFcCsf|jrb|j}|��|jks|rb|��}|j}t|�|jkrP|ttdt|���||�t	�
�|_dS)N�<Q)rqrx�_FRAME_SIZE_TARGET�	getbufferrp�len�_FRAME_SIZE_MIN�FRAMEr
rrrs)r#rw�f�data�writerrrry�sz_Framer.commit_framecCs |jr|j�|�S|�|�SdSr )rqr�rp�r#r�rrrr��sz
_Framer.writecCs,|j}|jr|jdd�||�||�dS)NTrv)rprqry)r#�headerZpayloadr�rrr�write_large_bytes�s
z_Framer.write_large_bytesN)F)rrrrr|r$rurzryr�r�rrrrro�s
roc@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�	_UnframerNcCs||_||_d|_dSr )�	file_read�
file_readlinerq)r#r�r�Z	file_tellrrrr$	sz_Unframer.__init__cCs�|jrb|j�|�}|dkrJt|�dkrJd|_t|�}|�|�|dd�<|S|t|�kr^td��|St|�}|�|�|dd�<|SdS�Nr�$pickle exhausted before end of frame)rq�readintor~r�r)r#�buf�nrrrr�s�z_Unframer.readintocCsT|jrF|j�|�}|s.|dkr.d|_|�|�St|�|krBtd��|S|�|�SdSr�)rq�readr�r~r�r#r�r�rrrr�s
�z_Unframer.readcCsF|jr:|j��}|s"d|_|��S|ddkr6td��|S|��SdS)N����
r�)rq�readliner�rr�rrrr�,s
�z_Unframer.readlinecCs2|jr|j��dkrtd��t�|�|��|_dS)N�z4beginning of a new frame before end of current frame)rqr�rrrrsr��r#Z
frame_sizerrr�
load_frame9s
�z_Unframer.load_frame)N)rrrr$r�r�r�r�rrrrr�s



r�c	Csj|�d�D]V}|dkr&td�||���z|}t||�}Wq
tk
r^td�||��d�Yq
Xq
||fS)N�.z<locals>z&Can't get local attribute {!r} on {!r}z Can't get attribute {!r} on {!r})�split�AttributeError�format�getattr)�obj�nameZsubpath�parentrrr�
_getattributeBs"���
r�c	Cs�t|dd�}|dk	r|Stj����D]X\}}|dks&|dks&|dkrHq&z t||�d|krf|WSWq&tk
r|Yq&Xq&dS)z$Find the module an object belong to.rN�__main__Z__mp_main__r)r��sys�modules�copy�itemsr�r�)r�r��module_name�modulerrr�whichmoduleOs ��r�cCsh|dkrdS|��d?d}|j|ddd�}|dkrd|dkrd|dd	krd|d
d@dkrd|dd�}|S)
a�Encode 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'
    >>>
    rr����littleT��	byteorderZsignedr������N)�
bit_length�to_bytes)rm�nbytes�resultrrr�encode_longbsr�cCstj|ddd�S)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
    r�Tr�)�int�
from_bytes)r�rrr�decode_long�sr�c@s�eZdZd;ddd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zd<dd�Z	dd�Z
dd�Zd=dd�ZiZ
dd�Zee
ed�<dd�Zee
e<dd�Zee
e<dd�Zee
e<d d!�Zee
e<d"d#�Zee
e<er�d$d%�Zee
e<d&d'�Zee
e<d(d)�Zee
e <d*d+�Z!e!e
e"<d,Z#d-d.�Z$d/d0�Z%e%e
e&<e'dk	�r@e%e
e'<d1d2�Z(d3d4�Z)e)e
e*<d5d6�Z+e+e
e,<d>d7d8�Z-d9d:�Z.e-e
e/<e.e
e<dS)?�_PicklerNT��fix_imports�buffer_callbackcCs�|dkrt}|dkrt}n"d|kr.tks<ntdt��|dk	rT|dkrTtd��||_z|j|_Wntk
r�td��YnXt|j�|_	|j	j|_|j	j
|_i|_t
|�|_|dk|_d|_|o�|dk|_dS)	a!This takes a binary file for writing a pickle data stream.

        The optional *protocol* argument tells the pickler to use the
        given protocol; supported protocols are 0, 1, 2, 3, 4 and 5.
        The default protocol is 4. It was introduced in Python 3.4, and
        is incompatible with previous versions.

        Specifying a negative protocol version selects the highest
        protocol version supported.  The higher the protocol used, the
        more recent the version of Python needed to read the pickle
        produced.

        The *file* argument must have a write() method that accepts a
        single bytes argument. It can thus be a file object opened for
        binary writing, an io.BytesIO instance, or any other custom
        object that meets this interface.

        If *fix_imports* is True and *protocol* is less than 3, pickle
        will try to map the new Python 3 names to the old module names
        used in Python 2, so that the pickle data stream is readable
        with Python 2.

        If *buffer_callback* is None (the default), buffer views are
        serialized into *file* as part of the pickle stream.

        If *buffer_callback* is not None, then it can be called any number
        of times with a buffer view.  If the callback returns a false value
        (such as None), the given buffer is out-of-band; otherwise the
        buffer is serialized in-band, i.e. inside the pickle stream.

        It is an error if *buffer_callback* is not None and *protocol*
        is None or smaller than 5.
        Nrzpickle protocol must be <= %drz#buffer_callback needs protocol >= 5z"file must have a 'write' attributer�r�)�DEFAULT_PROTOCOL�HIGHEST_PROTOCOL�
ValueError�_buffer_callbackr��_file_writer��	TypeErrorro�framerr��_write_large_bytes�memor��proto�bin�fastr�)r#�file�protocolr�r�rrrr$�s*#



z_Pickler.__init__cCs|j��dS)aClears the pickler's "memo".

        The memo is the data structure that remembers which objects the
        pickler has already seen, so that shared or recursive objects
        are pickled by reference and not by value.  This method is
        useful when re-using picklers.
        N)r��clearrtrrr�
clear_memo�sz_Pickler.clear_memocCsrt|d�std|jjf��|jdkr<|�ttd|j��|jdkrP|j�	�|�
|�|�t�|j��dS)z7Write a pickled representation of obj to the open file.r�z2Pickler.__init__() was not called by %s.__init__()��<BrN)
�hasattrr
�	__class__rr�r��PROTOr
r�ru�save�STOPrz�r#r�rrrr�s
�




z
_Pickler.dumpcCsL|jr
dSt|�|jkst�t|j�}|�|�|��||f|jt|�<dS)zStore an object in the memo.N)r��idr��AssertionErrorr~r��put)r#r��idxrrr�memoize�s
z_Pickler.memoizecCsT|jdkrtS|jr:|dkr*ttd|�Sttd|�Sntt|��d�dSdS)Nr�r��<I�ascii�
)	r��MEMOIZEr��BINPUTr
�LONG_BINPUT�PUT�repr�encode)r#r�rrrr�s
z_Pickler.putcCs@|jr*|dkrttd|�Sttd|�Stt|��d�dS)Nr�r�r�r�r�)r��BINGETr
�LONG_BINGET�GETr�r��r#�irrr�gets
z_Pickler.getc
Cs�|j��|�|�}|dk	r.|r.|�|�dS|j�t|��}|dk	r^|�|�|d��dSt}t	|dd�}|dk	r~||�}|tk�r@t
|�}|j�|�}|dk	r�|||�dSt	|dt��|�}|dk	r�||�}njt
|t
�r�|�|�dSt	|dd�}|dk	�r||j�}n0t	|dd�}|dk	�r.|�}ntd|j|f��t|t��r\|�||�dSt|t��sttd|��t|�}	d|	k�r�d	k�s�ntd
|��|j|d|i�dS)NrZreducer_overrider�
__reduce_ex__�
__reduce__zCan't pickle %r object: %rz%s must return string or tupler��z2Tuple returned by %s must have two to six elementsr�)r�ry�
persistent_id�	save_persr�r�r�r��NotImplementedr��type�dispatchr�
issubclass�save_globalr�r
r�
isinstance�str�tupler~�save_reduce)
r#r��save_persistent_id�pidrm�rv�reduce�tr��lrrrr�sZ









��z
_Pickler.savecCsdSr rr�rrrr�]sz_Pickler.persistent_idcCsb|jr |j|dd�|�t�n>z |�tt|��d�d�Wntk
r\td��YnXdS)NF)r�r�r��2persistent IDs in protocol 0 must be ASCII strings)	r�r�r��	BINPERSID�PERSIDr�r��UnicodeEncodeErrorr
�r#r�rrrr�as �z_Pickler.save_persc
Cs>t|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�|jdk�r^|
dk�r^|d
}t|d��std��|dk	�r8||j
k	�r8td��|dd�}||�||�|	t�n||�||�|	t�|dk	�r�t|�|jk�r�|	t|�|jt|�d
��n
|�|�|dk	�r�|�|�|dk	�r�|�|�|dk	�r:|dk�r
||�|	t�n0||�||�||�|	t�|	t�|	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�r�r�r�r�r�r��	NEWOBJ_EXrr�REDUCE�NEWOBJr�r��POPr�r��_batch_appends�_batch_setitems�BUILD�TUPLE2)
r#�func�args�stateZ	listitemsZ	dictitemsZstate_setterr�r�r�Z	func_name�cls�kwargsrrrr�msz


��


��

"







z_Pickler.save_reducecCs|�t�dSr )r��NONEr�rrr�	save_none�sz_Pickler.save_nonecCs4|jdkr|�|rtnt�n|�|r*tnt�dS)Nr�)r�r��NEWTRUE�NEWFALSE�TRUE�FALSEr�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�dk�rnn|�tt|��
d�d�n|�tt|��
d�d
�dS)Nrr�r���<Hi�i����<ir�r�r�r�sL
)r�r��BININT1r
�BININT2�BININTr�r�r~�LONG1�LONG4�INTr�r��LONG�r#r�Zencodedr�rrr�	save_long�s*
z_Pickler.save_longcCs<|jr|�ttd|��n|�tt|��d�d�dS)N�>dr�r�)r�r��BINFLOATr
�FLOATr�r�r�rrr�
save_floatsz_Pickler.save_floatcCs�|jdkr@|s |jtd|d�n|jtjt|d�df|d�dSt|�}|dkrj|�tt	d|�|�nf|dkr�|jdkr�|�
tt	d	|�|�n<||jj
kr�|�
tt	d
|�|�n|�tt	d
|�|�|�|�dS)Nr�r�r��latin1r�r����rr{r�)r�r��bytes�codecsr�r�r~r��SHORT_BINBYTESr
r��	BINBYTES8r�r|�BINBYTESr��r#r�r�rrr�
save_bytess"
�z_Pickler.save_bytescCs�|jdkr:|s |jtd|d�n|jtt|�f|d�dSt|�}||jjkrf|�tt	d|�|�n|�
tt	d|�|�dS)Nrrr+r{)r�r��	bytearrayr.r~r�r|r��
BYTEARRAY8r
r�r3rrr�save_bytearray)s
z_Pickler.save_bytearrayc	Cs�|jdkrtd��|���t}|js*td��d}|jdk	rFt|�|��}|rp|jr`|�|���q�|�	|���n|�
t�|jr�|�
t�W5QRXdS)Nrz0PickleBuffer can only pickled with protocol >= 5zHPickleBuffer can not be pickled when pointing to a non-contiguous bufferT)
r�r
�raw�
contiguousr��bool�readonlyr4�tobytesr7r��NEXT_BUFFER�READONLY_BUFFER)r#r��mZin_bandrrr�save_picklebuffer8s



z_Pickler.save_picklebuffercCs|jr�|�dd�}t|�}|dkrF|jdkrF|�ttd|�|�nf|dkrp|jdkrp|�ttd|�|�n<||j	j
kr�|�ttd|�|�n|�ttd|�|�nT|�d	d
�}|�dd�}|�d
d�}|�dd�}|�dd�}|�t
|�d�d�|�|�dS)N�utf-8�
surrogatepassr�rr�r-r{r��\z\u005c�z\u0000�
z\u000a�
z\u000d�z\u001a�raw-unicode-escaper�)r�r�r~r�r��SHORT_BINUNICODEr
r��BINUNICODE8r�r|�
BINUNICODE�replace�UNICODEr�r%rrr�save_strRs&�z_Pickler.save_strcCs:|s(|jr|�t�n|�tt�dSt|�}|j}|j}|dkr�|jdkr�|D]}||�qRt	|�|kr�|�
|t	|�d�}|�t||�n|�t|�|�
|�dS|j}|t�|D]}||�q�t	|�|k�r$|�
|t	|�d�}|j�r|t|�n|t|d|�dS|t�|�
|�dS)Nr�r�rr�)r�r��EMPTY_TUPLE�MARK�TUPLEr~r�r�r�r�r�r
�_tuplesize2coder��POP_MARK)r#r�r�r�r�Zelementr�r�rrr�
save_tupleis:


z_Pickler.save_tuplecCs8|jr|�t�n|�tt�|�|�|�|�dSr )r�r��
EMPTY_LISTrP�LISTr�rr�rrr�	save_list�s

z_Pickler.save_listi�cCs�|j}|j}|js0|D]}||�|t�qdSt|�}tt||j��}t|�}|dkr||t	�|D]}||�qd|t
�n|r�||d�|t�||jkr8dSq8dS�Nr�r)r�r�r��APPEND�iter�listr�
_BATCHSIZEr~rP�APPENDS)r#r�r�r�rm�it�tmpr�rrrr�s(



z_Pickler._batch_appendscCs<|jr|�t�n|�tt�|�|�|�|���dSr )r�r��
EMPTY_DICTrP�DICTr�rr�r�rrr�	save_dict�s

z_Pickler.save_dictc	Cs�|j}|j}|js<|D] \}}||�||�|t�qdSt|�}tt||j��}t|�}|dkr�|t	�|D]\}}||�||�qp|t
�n(|r�|d\}}||�||�|t�||jkrDdSqDdSrX)r�r�r��SETITEMrZr[rr\r~rP�SETITEMS)	r#r�r�r��k�vr^r_r�rrrr�s0



z_Pickler._batch_setitemscCs�|j}|j}|jdkr0|jtt|�f|d�dS|t�|�|�t|�}tt	||j
��}t|�}|dkr�|t�|D]}||�qv|t
�||j
krJdSqJdS�Nrr+r)r�r�r�r��setr[�	EMPTY_SETr�rZrr\r~rP�ADDITEMS)r#r�r�r�r^Zbatchr��itemrrr�save_set�s"



z_Pickler.save_setcCs�|j}|j}|jdkr0|jtt|�f|d�dS|t�|D]}||�q<t|�|jkr||t	|�
|jt|�d��dS|t�|�|�dSrg)
r�r�r�r��	frozensetr[rPr�r�rSr��	FROZENSETr�)r#r�r�r�rkrrr�save_frozensets

 z_Pickler.save_frozensetc

Csd|j}|j}|dkr t|dd�}|dkr.|j}t||�}z(t|dd�tj|}t||�\}}Wn.t	t
tfk
r�td|||f�d�YnX||k	r�td|||f��|j
dk�r&t�||f�}	|	�r&|	dks�t�|	dkr�|ttd|	��n0|	d	k�r|ttd
|	��n|ttd|	��dS|�d�d}
||k�rB|
}|j
d
k�rl|�|�|�|�|t�n�||k	�r�|�t||
f�n�|j
dk�r�|tt|d�dt|d�d�n�|j�rtj}tj}||f|k�r�|||f\}}n||k�r||}z(|tt|d�dt|d�d�Wn,tk
�rTt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�r�rrrr�rr�rAr�r�z?can't pickle global identifier '%s.%s' using pickle protocol %i)!r�r�r�rr��
__import__r�r�r��ImportError�KeyErrorr�r
r�rr�r��EXT1r
�EXT2�EXT4�
rpartitionr��STACK_GLOBALr��GLOBALr.r��_compat_pickleZREVERSE_NAME_MAPPINGZREVERSE_IMPORT_MAPPINGrr�)
r#r�r�r�r�r�r�Zobj2r��codeZlastnameZr_name_mappingZr_import_mappingrrrr�s�

�����





��
��

���z_Pickler.save_globalcCs`|td�kr|jtd|d�S|tt�kr:|jttf|d�S|td�krV|jtd|d�S|�|�S)Nr r+.).)r�r�r�r�r�rrr�	save_typeasz_Pickler.save_type)N)T)NNNNN)N)0rrrr$r�rr�r�r�r�r�r�r�r�rr�rr:r&r�r*�floatr4r.r7r5�_HAVE_PICKLE_BUFFERr@rrNr�rTr�rWr[r\rrb�dictr%rrlrhrormr�r}rrrrrr��sj�9
	
F�
u1		

B	r�c@s�eZdZddddd�dd�Zdd	�Zd
d�Zdd
�ZiZdd�Zeee	d<dd�Z
e
eed<dd�Zeee
d<dd�Zeeed<dd�Zeeed<dd�Zeeed<dd�Zeeed<dd�Zeeed<dd �Zeeed<d!d"�Zeeed<d#d$�Zeeed<d%d&�Zeeed<d'd(�Z e ee!d<d)d*�Z"e"ee#d<d+d,�Z$e$ee%d<d-d.�Z&e&ee'd<d/d0�Z(d1d2�Z)e)ee*d<d3d4�Z+e+ee,d<d5d6�Z-e-ee.d<d7d8�Z/e/ee0d<d9d:�Z1e1ee2d<d;d<�Z3e3ee4d<d=d>�Z5e5ee6d<d?d@�Z7e7ee8d<dAdB�Z9e9ee:d<dCdD�Z;e;ee<d<dEdF�Z=e=ee>d<dGdH�Z?e?ee@d<dIdJ�ZAeAeeBd<dKdL�ZCeCeeDd<dMdN�ZEeEeeFd<dOdP�ZGeGeeHd<dQdR�ZIeIeeJd<dSdT�ZKeKeeLd<dUdV�ZMeMeeNd<dWdX�ZOeOeePd<dYdZ�ZQeQeeRd<d[d\�ZSeSeeTd<d]d^�ZUeUeeVd<d_d`�ZWeWeeXd<dadb�ZYdcdd�ZZeZee[d<dedf�Z\e\ee]d<dgdh�Z^e^ee_d<didj�Z`e`eead<dkdl�Zbebeecd<dmdn�Zdedeeed<dodp�Zfefeegd<dqdr�Zheheeid<dsdt�Zjejeekd<dudv�Zldwdx�Zmdydz�Zneneeod<d{d|�Zpepeeqd<d}d~�Zrereesd<dd��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�ee�d<d�d��Z�e�ee�d<d�d��Z�e�ee�d<d�d��Z�e�ee�d<d�d��Z�e�ee�d<d�d��Z�e�ee�d<d�d��Z�e�ee�d<d�d��Z�e�ee�d<d�d��Z�e�ee�d<d�d��Z�e�ee�d<dS)��
_UnpicklerT�ASCII�strictN�r��encoding�errors�bufferscCsH|dk	rt|�nd|_|j|_|j|_i|_||_||_d|_	||_
dS)a�This takes a binary file for reading a pickle data stream.

        The protocol version of the pickle is detected automatically, so
        no proto argument is needed.

        The argument *file* must have two methods, a read() method that
        takes an integer argument, and a readline() method that requires
        no arguments.  Both methods should return bytes.  Thus *file*
        can be a binary file object opened for reading, an io.BytesIO
        object, or any other custom object that meets this interface.

        The file-like object must have two methods, a read() method
        that takes an integer argument, and a readline() method that
        requires no arguments.  Both methods should return bytes.
        Thus file-like object can be a binary file object opened for
        reading, a BytesIO object, or any other custom object that
        meets this interface.

        If *buffers* is not None, it should be an iterable of buffer-enabled
        objects that is consumed each time the pickle stream references
        an out-of-band buffer view.  Such buffers have been given in order
        to the *buffer_callback* of a Pickler object.

        If *buffers* is None (the default), then the buffers are taken
        from the pickle stream, assuming they are serialized there.
        It is an error for *buffers* to be None if the pickle stream
        was produced with a non-None *buffer_callback*.

        Other optional arguments are *fix_imports*, *encoding* and
        *errors*, which are used to control compatibility support for
        pickle stream generated by Python 2.  If *fix_imports* is True,
        pickle will try to map the old Python 2 names to the new names
        used in Python 3.  The *encoding* and *errors* tell pickle how
        to decode 8-bit string instances pickled by Python 2; these
        default to 'ASCII' and 'strict', respectively. *encoding* can be
        'bytes' to read theses 8-bit string instances as bytes objects.
        Nr)rZ�_buffersr��_file_readliner��
_file_readr�r�r�r�r�)r#r�r�r�r�r�rrrr$rs'z_Unpickler.__init__c
Cs�t|d�std|jjf��t|j|j�|_|jj|_|jj	|_	|jj
|_
g|_g|_|jj
|_
d|_|j}|j}z4|d�}|s�t�t|t�s�t�||d|�qtWn,tk
r�}z|jWY�Sd}~XYnXdS)z�Read a pickled object representation from the open file.

        Return the reconstituted object hierarchy specified in the file.
        r�z4Unpickler.__init__() was not called by %s.__init__()rr�N)r�rr�rr�r�r��	_unframerr�r�r��	metastack�stack�appendr�r��EOFErrorr��bytes_typesr�rr!)r#r�r��keyZstopinstrrrr�s,
�



z_Unpickler.loadcCs |j}|j��|_|jj|_|Sr )r�r��popr��r#r�rrr�pop_mark�s
z_Unpickler.pop_markcCstd��dS)Nz%unsupported persistent id encountered)rrrrr�persistent_load�sz_Unpickler.persistent_loadcCs:|�d�d}d|kr"tks0ntd|��||_dS)Nr�rzunsupported pickle protocol: %d)r�r�r�r�)r#r�rrr�
load_proto�sz_Unpickler.load_protorcCs8td|�d��\}|tjkr(td|��|j�|�dS)Nr{�zframe size > sys.maxsize: %d)rr�r�r	r�r�r�r�rrrr��s
z_Unpickler.load_framecCsLz|��dd��d�}Wntk
r6td��YnX|�|�|��dS)Nr�r�r�)r��decode�UnicodeDecodeErrorrr�r�rrrr�load_persid�s�
z_Unpickler.load_persidcCs|j��}|�|�|��dSr )r�r�r�r�rrrr�load_binpersid�s
z_Unpickler.load_binpersidcCs|�d�dSr �r�rtrrr�	load_none�sz_Unpickler.load_nonecCs|�d�dS)NFr�rtrrr�
load_false�sz_Unpickler.load_falsecCs|�d�dS)NTr�rtrrr�	load_true�sz_Unpickler.load_truecCsL|��}|tdd�krd}n |tdd�kr4d}n
t|d�}|�|�dS)Nr�FTr)r�rrr�r�)r#r��valrrr�load_int�s
z_Unpickler.load_intcCs|�td|�d��d�dS)Nrrr�r�rr�rtrrr�load_binint�sz_Unpickler.load_binintcCs|�|�d�d�dSrX)r�r�rtrrr�load_binint1sz_Unpickler.load_binint1cCs|�td|�d��d�dS)Nrr�rr�rtrrr�load_binint2sz_Unpickler.load_binint2cCs@|��dd�}|r,|ddkr,|dd�}|�t|d��dS)Nr��Lr)r�r�r�)r#r�rrr�	load_longsz_Unpickler.load_longcCs*|�d�d}|�|�}|�t|��dSrX)r�r�r�r�rrr�
load_long1s
z_Unpickler.load_long1cCs>td|�d��\}|dkr"td��|�|�}|�t|��dS)Nrrrz#LONG pickle has negative byte count)rr�rr�r�r�rrr�
load_long4s

z_Unpickler.load_long4cCs|�t|��dd���dS�Nr�)r�r~r�rtrrr�
load_float!sz_Unpickler.load_floatcCs|�td|�d��d�dS)Nr'r�rr�rtrrr�
load_binfloat%sz_Unpickler.load_binfloatcCs"|jdkr|S|�|j|j�SdS)Nr.)r�r�r�r"rrr�_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�r~rr�r�r/�
escape_decoder�rrr�load_string2s
(z_Unpickler.load_stringcCs@td|�d��\}|dkr"td��|�|�}|�|�|��dS)Nrrrz(BINSTRING pickle has negative byte count)rr�rr�r��r#r~r�rrr�load_binstring<s

z_Unpickler.load_binstringcCs:td|�d��\}|tkr&tdt��|�|�|��dS)Nr�rz2BINBYTES exceeds system's maximum size of %d bytes�rr�r	rr��r#r~rrr�
load_binbytesEs�z_Unpickler.load_binbytescCs |�t|��dd�d��dS)Nr�rH)r�r�r�rtrrr�load_unicodeMsz_Unpickler.load_unicodecCsBtd|�d��\}|tkr&tdt��|�t|�|�dd��dS)Nr�rz4BINUNICODE exceeds system's maximum size of %d bytesrArB�rr�r	rr�r�r�rrr�load_binunicodeQs�z_Unpickler.load_binunicodecCsBtd|�d��\}|tkr&tdt��|�t|�|�dd��dS)Nr{r�z5BINUNICODE8 exceeds system's maximum size of %d bytesrArBr�r�rrr�load_binunicode8Ys�z_Unpickler.load_binunicode8cCs:td|�d��\}|tkr&tdt��|�|�|��dS)Nr{r�z3BINBYTES8 exceeds system's maximum size of %d bytesr�r�rrr�load_binbytes8as�z_Unpickler.load_binbytes8cCsFtd|�d��\}|tkr&tdt��t|�}|�|�|�|�dS)Nr{r�z4BYTEARRAY8 exceeds system's maximum size of %d bytes)rr�r	rr5r�r�)r#r~�brrr�load_bytearray8is�
z_Unpickler.load_bytearray8cCsL|jdkrtd��zt|j�}Wntk
r<td��YnX|�|�dS)NzLpickle stream refers to out-of-band data but no *buffers* argument was givenznot enough out-of-band buffers)r�r�next�
StopIterationr�)r#r�rrr�load_next_bufferss
z_Unpickler.load_next_bufferc	Cs6|jd}t|��}|js(|��|jd<W5QRXdSr�)r��
memoryviewr;�
toreadonly)r#r�r?rrr�load_readonly_buffer~s

z_Unpickler.load_readonly_buffercCs,|�d�d}|�|�}|�|�|��dSrX)r�r�r�r�rrr�load_short_binstring�s
z_Unpickler.load_short_binstringcCs"|�d�d}|�|�|��dSrX)r�r�r�rrr�load_short_binbytes�sz_Unpickler.load_short_binbytescCs*|�d�d}|�t|�|�dd��dS)Nr�rrArB)r�r�r�r�rrr�load_short_binunicode�sz _Unpickler.load_short_binunicodecCs|��}|�t|��dSr )r�r�r�r�rrr�
load_tuple�sz_Unpickler.load_tuplecCs|�d�dS)Nrr�rtrrr�load_empty_tuple�sz_Unpickler.load_empty_tuplecCs|jdf|jd<dSr��r�rtrrr�load_tuple1�sz_Unpickler.load_tuple1cCs$|jd|jdfg|jdd�<dS)Nr�r�r�rtrrr�load_tuple2�sz_Unpickler.load_tuple2cCs,|jd|jd|jdfg|jdd�<dS)N���r�r�r�rtrrr�load_tuple3�sz_Unpickler.load_tuple3cCs|�g�dSr r�rtrrr�load_empty_list�sz_Unpickler.load_empty_listcCs|�i�dSr r�rtrrr�load_empty_dictionary�sz _Unpickler.load_empty_dictionarycCs|�t��dSr )r�rhrtrrr�load_empty_set�sz_Unpickler.load_empty_setcCs|��}|�t|��dSr )r�r�rmr�rrr�load_frozenset�sz_Unpickler.load_frozensetcCs|��}|�|�dSr )r�r�r�rrr�	load_list�sz_Unpickler.load_listcs4|����fdd�tdt��d�D�}|�|�dS)Ncsi|]}�|�|d�qS)r�r)rlr��r�rr�
<dictcomp>�s�z(_Unpickler.load_dict.<locals>.<dictcomp>rr�)r��ranger~r�)r#�drr�r�	load_dict�s

�z_Unpickler.load_dictc
Cs�|st|t�rt|d�rjz||�}Wqttk
rf}z$td|jt|�ft��d��W5d}~XYqtXn
|�|�}|�	|�dS)NZ__getinitargs__zin constructor for %s: %sr�)
r�r�r�r�rr�r��exc_inforr�)r#�klassrr!�errrrr�_instantiate�s��
�
z_Unpickler._instantiatecCsL|��dd��d�}|��dd��d�}|�||�}|�||���dS)Nr�r�)r�r��
find_classr�r��r#r�r�r�rrr�	load_inst�sz_Unpickler.load_instcCs"|��}|�d�}|�||�dS�Nr)r�r�r�)r#rrrrr�load_obj�s
z_Unpickler.load_objcCs2|j��}|j��}|j|f|��}|�|�dSr �r�r�rr�)r#rrr�rrr�load_newobj�s

z_Unpickler.load_newobjcCs>|j��}|j��}|j��}|j|f|�|�}|�|�dSr r�)r#rrrr�rrr�load_newobj_ex�s



z_Unpickler.load_newobj_excCsF|��dd��d�}|��dd��d�}|�||�}|�|�dS)Nr�rA)r�r�r�r�r�rrr�load_global�sz_Unpickler.load_globalcCsJ|j��}|j��}t|�tk	s,t|�tk	r4td��|�|�||��dS)NzSTACK_GLOBAL requires str)r�r�r�r�rr�r�)r#r�r�rrr�load_stack_global�s


z_Unpickler.load_stack_globalcCs|�d�d}|�|�dSrX)r��
get_extension�r#r|rrr�	load_ext1sz_Unpickler.load_ext1cCs td|�d��\}|�|�dS)Nrr��rr�r�r�rrr�	load_ext2	sz_Unpickler.load_ext2cCs td|�d��\}|�|�dS)Nrrr�r�rrr�	load_ext4sz_Unpickler.load_ext4cCspg}t�||�}||k	r&|�|�dSt�|�}|sP|dkrDtd��td|��|j|�}|t|<|�|�dS)NrzEXT specifies code <= 0zunregistered extension code %d)rr�r�rrr�r�)r#r|Znilr�r�rrrr�s


z_Unpickler.get_extensioncCs�t�d||�|jdkrT|jrT||ftjkr@tj||f\}}n|tjkrTtj|}t|dd�|jdkr~ttj	||�dSt
tj	||�SdS)Nzpickle.find_classr�rrpr)r��auditr�r�r{ZNAME_MAPPINGZIMPORT_MAPPINGrrr�r�r�)r#r�r�rrrr�#s


z_Unpickler.find_classcCs&|j}|��}|d}||�|d<dSr��r�r�)r#r�rrrrr�load_reduce1sz_Unpickler.load_reducecCs|jr|jd=n|��dSr�)r�r�rtrrr�load_pop8s
z_Unpickler.load_popcCs|��dSr )r�rtrrr�
load_pop_mark?sz_Unpickler.load_pop_markcCs|�|jd�dSr�)r�r�rtrrr�load_dupCsz_Unpickler.load_dupcCs(t|��dd��}|�|j|�dSr�)r�r�r�r�r�rrr�load_getGsz_Unpickler.load_getcCs"|�d�d}|�|j|�dSrX)r�r�r�r�rrr�load_bingetLsz_Unpickler.load_bingetcCs&td|�d��\}|�|j|�dS)Nr�r)rr�r�r�r�rrr�load_long_bingetQsz_Unpickler.load_long_bingetcCs8t|��dd��}|dkr$td��|jd|j|<dS)Nr�rznegative PUT argument)r�r�r�r�r�r�rrr�load_putVsz_Unpickler.load_putcCs2|�d�d}|dkrtd��|jd|j|<dS)Nr�rznegative BINPUT argumentr�)r�r�r�r�r�rrr�load_binput]sz_Unpickler.load_binputcCs6td|�d��\}|tkr"td��|jd|j|<dS)Nr�rznegative LONG_BINPUT argumentr�)rr�r	r�r�r�r�rrr�load_long_binputdsz_Unpickler.load_long_binputcCs|j}|jd|t|�<dSr�)r�r�r~)r#r�rrr�load_memoizeksz_Unpickler.load_memoizecCs$|j}|��}|d}|�|�dSr�)r�r�r�)r#r�r!r[rrr�load_appendpsz_Unpickler.load_appendcCsZ|��}|jd}z
|j}Wntk
r0YnX||�dS|j}|D]}||�qHdSr�)r�r��extendr�r�)r#r�Zlist_objr�r�rkrrr�load_appendsws

z_Unpickler.load_appendscCs*|j}|��}|��}|d}|||<dSr�r�)r#r�r!r�r�rrr�load_setitem�s
z_Unpickler.load_setitemcCs@|��}|jd}tdt|�d�D]}||d|||<q"dS)Nr�rr�r�)r�r�r�r~)r#r�r�r�rrr�
load_setitems�s
z_Unpickler.load_setitemscCsD|��}|jd}t|t�r(|�|�n|j}|D]}||�q2dSr�)r�r�r�rh�update�add)r#r�Zset_objr�rkrrr�
load_additems�s

z_Unpickler.load_additemsc
Cs�|j}|��}|d}t|dd�}|dk	r6||�dSd}t|t�rXt|�dkrX|\}}|r�|j}tj}|�	�D]*\}}	t
|�tkr�|	|||�<qp|	||<qp|r�|�	�D]\}}	t|||	�q�dS)Nr��__setstate__r�)
r�r�r�r�r�r~�__dict__r��internr�r�r��setattr)
r#r�r�inst�setstateZ	slotstateZ	inst_dictrrerfrrr�
load_build�s(
z_Unpickler.load_buildcCs"|j�|j�g|_|jj|_dSr )r�r�r�rtrrr�	load_mark�sz_Unpickler.load_markcCs|j��}t|��dSr )r�r�rr"rrr�	load_stop�s
z_Unpickler.load_stop)�rrrr$rr�r�r�r�r�r�r�r�r�r�r�r�rr�rr�rr�r#r�r r�rr�rr�r$r�r!r�r"r�r)r�r(r�r��STRINGr��	BINSTRINGr�r2r�rMr�rKr�rJr�r1r�r6r�r=r�r>r��SHORT_BINSTRINGr�r0r�rIr�rQr�rOr��TUPLE1r�rr��TUPLE3r�rUr�r`r�rir�rnr�rVr�rar�r��INSTr��OBJr�r	r�rr�rzr�ryr�rur�rvr�rwr�r�r�rr�r
r�rSr��DUPr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rYr�r]r�rcr�rdr�rjrr
rrPrr�rrrrr�ps*�0				r�r�cCst||||d��|�dS�Nr�)r�r)r�r�r�r�r�rrr�_dump�s
��rcCs8t��}t||||d��|�|��}t|t�s4t�|Sr)rrrsr�r�getvaluer�r�r�)r�r�r�r�r��resrrr�_dumps�s��rr�r�r�cCst|||||d���S)N�r�r�r�r�)r�r)r�r�r�r�r�rrr�_load�s�rcCs2t|t�rtd��t�|�}t|||||d���S)Nz%Can't load pickle from unicode stringr)r�r�r�rrrsr�r)�sr�r�r�r�r�rrr�_loads�s

�r)	rr
rrrrrrrcCsddl}|��Sr�)�doctestZtestmod)rrrr�_test�srr�z$display contents of the pickle files)Zdescription�pickle_file�br�*zthe pickle file)r��nargs�helpz-tz--test�
store_truezrun self-test suite)�actionrz-vz)run verbosely; only affects self-test run)N)N)�r�typesr�copyregrrrr�	itertoolsr�	functoolsrr�r	Zstructr
rrjrrr/r{�__all__�_picklerr�rrsr.r5r�Zformat_versionZcompatible_formatsr�r��	Exceptionrr
rrZorg.python.corer%rPr�r
rSrr)r#r rr$rrr�r�rrr	r
rMrKrYr
rzrar`r]r�r�r
r�rVrUrr�r�r�rcrQrOrdr(rrr�r	rurvrwrrrrrr!r"rRr2r0rIrJr1rirjrnrryr�r�r6r=r>r��dirror�r�r�r�r�r�r�rrrrrrrrrrrr�argparse�ArgumentParser�parser�add_argumentZFileType�
parse_argsrZtestrZ
print_helpZpprintr�r�rrrr�<module>sh�

�

?;
^]��	0

����