Your IP : 3.144.28.90


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/pickle.cpython-34.pyc

�
f f���@s�dZddlmZddlmZddlmZmZmZddlm	Z	ddl
Z
ddl
mZddlm
Z
mZddlZddlZddlZddlZd	d
ddd
ddddg	ZeefZdZdddddddgZdZdZGdd	�d	e�ZGdd
�d
e�ZGdd�de�ZGdd�de�Zydd 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-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`ZcdaZddbZedcZfejgddde�eh�D��Gdfdg�dg�ZiGdhdi�di�Zjdjdkdl�Zkdjdmdn�Zldodp�Zmdqdr�ZnGdsdt�dt�ZoGdudv�dv�Zpddwdxdydz�Zqddwdxd{d|�Zrdwdxd}d~dd�d�d��Zsdwdxd}d~dd�d�d��ZtyDdd�lumZmZmZmvZvmwZwmxZxmyZymzZzm{Z{WnBe"k
r�eoepf\ZvZweqeresetf\ZxZyZzZ{YnXd�d��Z|e}d�kr�ddl~Z~e~jd�d��Z�e�j�d�d�e~j�d��d�d�d�d��e�j�d�d�d�d�d�d��e�j�d�d�d�d�d��e�j��Z�e�j�rye|�nPe�j�r�e�j��n9ddl�Z�x*e�j�D]Z�eze��Z�e�j�e��q�WndS)�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)�isliceN)�maxsize)�pack�unpack�PickleError�
PicklingError�UnpicklingError�Pickler�	Unpickler�dump�dumps�load�loadsz4.0z1.0z1.1z1.2z1.3z2.0z3.0��c@seZdZdZdS)rz6A common base class for the other pickling exceptions.N)�__name__�
__module__�__qualname__�__doc__�rr�+/opt/alt/python34/lib64/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@seZdZdd�ZdS)�_StopcCs
||_dS)N)�value)�selfrrrr�__init__Xsz_Stop.__init__N)rrrrrrrrrWsr)�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
s�s�s�s�s�s�s�s�s�s�s�s��B�Cs�s�s�s�s�s�s�s�s�s�cCs(g|]}tjd|�r|�qS)z[A-Z][A-Z0-9_]+$)�re�match)�.0�xrrr�
<listcomp>�s	rPc@sUeZdZdZdd�Zdd�Zdd�Zd	d
d�Zdd
�ZdS)�_Framer�@icCs||_d|_dS)N)�
file_write�
current_frame)rrSrrrr�s	z_Framer.__init__cCstj�|_dS)N)�io�BytesIOrT)rrrr�
start_framing�sz_Framer.start_framingcCs>|jr:|jj�dkr:|jdd�d|_ndS)Nr�forceT)rT�tell�commit_frame)rrrr�end_framing�sz_Framer.end_framingFcCs�|jr�|j}|j�|jks-|r�|j��C}t|�}|j}|t�|td|��||�WdQX|jd�|j	�q�ndS)Nz<Qr)
rTrY�_FRAME_SIZE_TARGET�	getbuffer�lenrS�FRAMEr	�seek�truncate)rrX�f�data�n�writerrrrZ�s			

z_Framer.commit_framecCs*|jr|jj|�S|j|�SdS)N)rTrerS)rrcrrrre�s	z
_Framer.writeNi)	rrrr\rrWr[rZrerrrrrQ�s
rQc@sCeZdZddd�Zdd�Zdd�Zdd	�ZdS)
�	_UnframerNcCs||_||_d|_dS)N)�	file_read�
file_readlinerT)rrgrhZ	file_tellrrrr�s		z_Unframer.__init__cCsz|jri|jj|�}|rD|dkrDd|_|j|�St|�|kretd��n|S|j|�SdS)Nrz$pickle exhausted before end of frame)rT�readrgr^r
)rrdrcrrrri�s		
z_Unframer.readcCsb|jrT|jj�}|s1d|_|j�S|ddkrPtd��n|S|j�SdS)N�s
rz$pickle exhausted before end of frame����
)rT�readlinerhr
)rrcrrrrm�s		
z_Unframer.readlinecCsL|jr-|jj�dkr-td��ntj|j|��|_dS)N�z4beginning of a new frame before end of current frame)rTrir
rUrVrg)r�
frame_sizerrr�
load_frame�sz_Unframer.load_frame)rrrrrirmrprrrrrf�s

rfFcCs�|jd�}|rGt|�dkrGtddj||���nxu|D]m}|dkr{tdj||���nyt||�}WqNtk
r�tdj||���YqNXqNW|S)N�.rjz,Can't get qualified attribute {!r} on {!r}; z$use protocols >= 4 to enable supportz<locals>z&Can't get local attribute {!r} on {!r}z Can't get attribute {!r} on {!r})�splitr^�AttributeError�format�getattr)�obj�name�allow_qualnameZdotted_pathZsubpathrrr�
_getattributes
	
	rycCs�t|dd�}|dk	r"|Sxvttjj��D]_\}}|dks8|dkrbq8ny t|||�|kr�|SWq8tk
r�Yq8Xq8WdS)z$Find the module an object belong to.rN�__main__)ru�list�sys�modules�itemsryrs)rvrwrx�module_name�modulerrr�whichmodules"
	r�cCs�|dkrdS|j�d?d}|j|dddd�}|dkr�|dkr�|d
d	kr�|dd@dkr�|dd�}q�n|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'
    >>>
    rrnrrj�	byteorder�little�signedT���Nrk���rk)�
bit_length�to_bytes)rO�nbytes�resultrrr�encode_long's$r�cCstj|dddd�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�r�r�T)�int�
from_bytes)rcrrr�decode_longEsr�c@seZdZddddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zddd�Z	dd�Z
dd�Zdddddd�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	r�e e
e"<nd-d.�Z#d/d0�Z$e$e
e%<d1d2�Z&e&e
e'<dd3d4�Z(d5d6�Z)e(e
e*<e)e
e<dS)7�_PicklerN�fix_importsTcCs�|dkrt}n|dkr*t}n/d|koAtknsYtdt��ny|j|_Wntk
r�td��YnXt|j�|_|jj|_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 and 4.  The
        default protocol is 3; a backward-incompatible protocol designed
        for Python 3.

        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.
        Nrzpickle protocol must be <= %dz"file must have a 'write' attributerjr)�DEFAULT_PROTOCOL�HIGHEST_PROTOCOL�
ValueErrorre�_file_writers�	TypeErrorrQ�framer�memor��proto�bin�fastr�)r�file�protocolr�rrrr^s"		
		z_Pickler.__init__cCs|jj�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��clear)rrrr�
clear_memo�sz_Pickler.clear_memocCs�t|d�s+td|jjf��n|jdkrZ|jttd|j��n|jdkry|jj	�n|j
|�|jt�|jj�dS)z7Write a pickled representation of obj to the open file.r�z2Pickler.__init__() was not called by %s.__init__()r�z<BrN)
�hasattrr�	__class__rr�re�PROTOr	r�rW�save�STOPr[)rrvrrrr�s 

z
_Pickler.dumpcCsj|jr
dSt|�|jks(t�t|j�}|j|j|��||f|jt|�<dS)zStore an object in the memo.N)r��idr��AssertionErrorr^re�put)rrv�idxrrr�memoize�s	z_Pickler.memoizecCsl|jdkrtS|jrM|dkr9ttd|�Sttd|�Sntt|�jd�dSdS)Nr�z<Bz<I�asciis
)	r��MEMOIZEr��BINPUTr	�LONG_BINPUT�PUT�repr�encode)rr�rrrr��s	z_Pickler.putcCsU|jr:|dkr&ttd|�Sttd|�Sntt|�jd�dS)Nr�z<Bz<Ir�s
)r��BINGETr	�LONG_BINGET�GETr�r�)r�irrr�get�s
	z_Pickler.getcCsA|jj�|j|�}|dk	r?|r?|j|�dS|jjt|��}|dk	r�|j|j|d��dSt|�}|j	j|�}|dk	r�|||�dSt
|dt�j|�}|dk	r�||�}n�yt|t�}	Wnt
k
rd}	YnX|	r7|j|�dSt
|dd�}|dk	rg||j�}nCt
|dd�}|dk	r�|�}ntd|j|f��t|t�r�|j||�dSt|t�s�td|��nt|�}
d|
kod	kns*td
|��n|jd||�dS)NrrF�
__reduce_ex__�
__reduce__zCan't pickle %r object: %rz%s must return string or tupler��z3Tuple returned by %s must have two to five elementsrv)r�rZ�
persistent_id�	save_persr�r�r�re�type�dispatchrur�
issubclassr��save_globalr�rr�
isinstance�str�tupler^�save_reduce)rrv�save_persistent_id�pidrO�trb�reduce�rvZissc�lrrrr��sT





z
_Pickler.savecCsdS)Nr)rrvrrrr�sz_Pickler.persistent_idcCsT|jr,|j|dd�|jt�n$|jtt|�jd�d�dS)Nr�Fr�s
)r�r�re�	BINPERSID�PERSIDr�r�)rr�rrrr�s	z_Pickler.save_perscCs�t|t�std��nt|�s9td��n|j}|j}t|dd�}	|jdkr|	dkr|\}
}}t|
d�s�tdj	|	���n|dk	r�|
|j
k	r�td	j	|	���n||
�||�||�|t�n�|jd
kr�|	dkr�|d}
t|
d�sOtd
��n|dk	ry|
|j
k	rytd��n|dd�}||
�||�|t�n||�||�|t
�|dk	r$t|�|jkr|t|j|jt|�d��q$|j|�n|dk	r@|j|�n|dk	r\|j|�n|dk	r||�|t�ndS)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 classr��
__newobj__rz+args[0] from __newobj__ args has no __new__z0args[0] from __newobj__ args has the wrong classrj)r�r�r�callabler�rerur�r�rtr��	NEWOBJ_EX�NEWOBJ�REDUCEr�r��POPr�r��_batch_appends�_batch_setitems�BUILD)r�func�args�stateZ	listitemsZ	dictitemsrvr�reZ	func_name�cls�kwargsrrrr�sZ				










+
z_Pickler.save_reducecCs|jt�dS)N)re�NONE)rrvrrr�	save_nonezsz_Pickler.save_nonecCsH|jdkr+|j|r!tnt�n|j|r=tnt�dS)Nr�)r�re�NEWTRUE�NEWFALSE�TRUE�FALSE)rrvrrr�	save_bool~sz_Pickler.save_boolcCsG|jr�|dkrl|dkr?|jttd|��dS|dkrl|jttd|��dSnd
|ko�dknr�|jttd|��dSn|jd	krt|�}t|�}|d
kr�|jt	td|�|�n|jt
td|�|�dS|jtt|�j
d�d�dS)Nrr�z<Bi��z<Hli���z<ir�r�r�sL
i�)r�re�BININT1r	�BININT2�BININTr�r�r^�LONG1�LONG4�LONGr�r�)rrv�encodedrdrrr�	save_long�s&	!z_Pickler.save_longcCsN|jr&|jttd|��n$|jtt|�jd�d�dS)Nz>dr�s
)r�re�BINFLOATr	�FLOATr�r�)rrvrrr�
save_float�s	z_Pickler.save_floatcCs�|jdkrZ|s.|jtfd|�n(|jtjt|d�dfd|�dSt|�}|dkr�|jtt	d|�|�nZ|dkr�|jdkr�|jt
t	d|�|�n|jtt	d	|�|�|j|�dS)
Nrrv�latin1r�z<Bl��rz<Qz<I)
r�r��bytes�codecsr�r�r^re�SHORT_BINBYTESr	�	BINBYTES8�BINBYTESr�)rrvrdrrr�
save_bytes�s!!z_Pickler.save_bytescCs|jr�|jdd�}t|�}|dkrc|jdkrc|jttd|�|�q|dkr�|jdkr�|jttd|�|�q|jttd|�|�nB|j	d	d
�}|j	dd�}|jt
|jd
�d�|j|�dS)Nzutf-8�
surrogatepassr�rz<Bl��z<Qz<I�\z\u005c�
z\u000azraw-unicode-escapes
)r�r�r^r�re�SHORT_BINUNICODEr	�BINUNICODE8�
BINUNICODE�replace�UNICODEr�)rrvr�rdrrr�save_str�s	!!!z_Pickler.save_strcCs�|s4|jr|jt�n|jtt�dSt|�}|j}|j}|dkr�|jdkr�x|D]}||�qtWt	|�|kr�|j
|t	|�d�}|jt||�n|jt|�|j
|�dS|j}|t�x|D]}||�qWt	|�|kr�|j
|t	|�d�}|jrh|t|�n|t|d|�dS|t�|j
|�dS)Nrr�rrj)r�re�EMPTY_TUPLE�MARK�TUPLEr^r�r�r�r�r�r��_tuplesize2coder��POP_MARK)rrvrdr�r��elementr�rerrr�
save_tuple�s:			

	

	
z_Pickler.save_tuplecCsH|jr|jt�n|jtt�|j|�|j|�dS)N)r�re�
EMPTY_LISTr�LISTr�r�)rrvrrr�	save_list�s
	
z_Pickler.save_listi�cCs�|j}|j}|jsDx"|D]}||�|t�q"WdSt|�}x�tt||j��}t|�}|dkr�|t	�x|D]}||�q�W|t
�n!|r�||d�|t�n||jkrSdSqSWdS)Nrjr)r�rer��APPEND�iterr{r�
_BATCHSIZEr^r�APPENDS)rr~r�rerO�it�tmprdrrrr�s*			





z_Pickler._batch_appendscCsN|jr|jt�n|jtt�|j|�|j|j��dS)N)r�re�
EMPTY_DICTr�DICTr�r�r~)rrvrrr�	save_dict's
	
z_Pickler.save_dictc	Cs'|j}|j}|jsTx2|D]*\}}||�||�|t�q"WdSt|�}x�tt||j��}t|�}|dkr�|t	�x(|D] \}}||�||�q�W|t
�n7|r|d\}}||�||�|t�n||jkrcdSqcWdS)Nrjr)r�rer��SETITEMrr{rrr^r�SETITEMS)	rr~r�re�k�vrrrdrrrr�4s2			







z_Pickler._batch_setitemscCs�|j}|j}|jdkrD|jtt|�fd|�dS|t�|j|�t|�}xytt	||j
��}t|�}|dkr�|t�x|D]}||�q�W|t
�n||j
krjdSqjWdS)Nrrvr)r�rer�r��setr{�	EMPTY_SETr�rrrr^r�ADDITEMS)rrvr�rerZbatchrd�itemrrr�save_setSs$		




z_Pickler.save_setcCs�|j}|j}|jdkrD|jtt|�fd|�dS|t�x|D]}||�qUWt|�|jkr�|t	|j
|jt|�d��dS|t�|j|�dS)Nrrvr)
r�rer�r��	frozensetr{rr�r�rr��	FROZENSETr�)rrvr�rerrrr�save_frozensetks		

(
z_Pickler.save_frozensetcCs|j}|j}|dkrB|jdkrBt|dd�}n|dkrZ|j}nt||d|jdk�}y?t|dd�tj|}t	||d|jdk�}Wn4t
ttfk
r�t
d|||f��Yn)X||k	rt
d|||f��n|jdkr�tj||f�}|r�|dksRt�|d	krx|ttd
|��n=|dkr�|ttd|��n|ttd
|��dSn|jdkr�|j|�|j|�|t�n|jdkr0|tt|d�dt|d�d�n�|jr�tj}	tj}
||f|	krv|	||f\}}q�||
kr�|
|}q�ny0|tt|d�dt|d�d�Wn.tk
r�t
d|||jf��YnX|j|�dS)Nrrrx�levelrz(Can't pickle %r: it's not found as %s.%sz2Can't pickle %r: it's not the same object as %s.%sr�r�z<Bi��z<Hz<irzutf-8s
r�z?can't pickle global identifier '%s.%s' using pickle protocol %i)rer�r�rurr��
__import__r|r}ry�ImportError�KeyErrorrsrrr�r��EXT1r	�EXT2�EXT4r��STACK_GLOBAL�GLOBALr�r��_compat_pickleZREVERSE_NAME_MAPPINGZREVERSE_IMPORT_MAPPING�UnicodeEncodeErrorr�)rrvrwrer�rr�Zobj2�codeZr_name_mappingZr_import_mappingrrrr��sf		
"


,			-
z_Pickler.save_globalcCs�|td�kr(|jtdd|�S|tt�krS|jttfd|�S|td�kr{|jtdd|�S|j|�S)Nrv.)N).)r�r��NotImplementedr�)rrvrrr�	save_type�sz_Pickler.save_type)+rrrrr�rr�r�r�r�r�r�r�r�r�r�r��boolr�r�r��floatr�r�r�r�rr�r	r{rr�r�dictr r�rrrrr�r,rrrrrr�\sV)
	B]




1
	
	



=	
r�c@s"eZdZdddddddd�Zd	d
�Zdd�Zd
d�ZiZdd�Zeee	d<dd�Z
e
eed<dd�Zeee
d<dd�Zeeed<dd�Zeeed<dd�Zeeed<dd�Zeeed<dd�Zeeed<d d!�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<d0d1�Z(d2d3�Z)e)ee*d<d4d5�Z+e+ee,d<d6d7�Z-e-ee.d<d8d9�Z/e/ee0d<d:d;�Z1e1ee2d<d<d=�Z3e3ee4d<d>d?�Z5e5ee6d<d@dA�Z7e7ee8d<dBdC�Z9e9ee:d<dDdE�Z;e;ee<d<dFdG�Z=e=ee>d<dHdI�Z?e?ee@d<dJdK�ZAeAeeBd<dLdM�ZCeCeeDd<dNdO�ZEeEeeFd<dPdQ�ZGeGeeHd<dRdS�ZIeIeeJd<dTdU�ZKeKeeLd<dVdW�ZMeMeeNd<dXdY�ZOeOeePd<dZd[�ZQeQeeRd<d\d]�ZSd^d_�ZTeTeeUd<d`da�ZVeVeeWd<dbdc�ZXeXeeYd<ddde�ZZeZee[d<dfdg�Z\e\ee]d<dhdi�Z^e^ee_d<djdk�Z`e`eead<dldm�Zbebeecd<dndo�Zdedeeed<dpdq�Zfdrds�Zgdtdu�Zheheeid<dvdw�Zjejeekd<dxdy�Zleleemd<dzd{�Zneneeod<d|d}�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�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�S)��
_Unpicklerr�T�encoding�ASCII�errors�strictcCsI|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.

        Optional keyword arguments are *fix_imports*, *encoding* and
        *errors*, which are used to control compatiblity 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.
        rN)	rm�_file_readlineri�
_file_readr�r1r3r�r�)rr�r�r1r3rrrr�s				z_Unpickler.__init__cCs t|d�s+td|jjf��nt|j|j�|_|jj|_|jj	|_	t
�|_g|_|jj
|_
d|_|j}|j}yMxF|d�}|s�t�nt|t�s�t�||d|�q�WWn,tk
r}z|jSWYdd}~XnXdS)z�Read a pickled object representation from the open file.

        Return the reconstituted object hierarchy specified in the file.
        r6z4Unpickler.__init__() was not called by %s.__init__()rrjN)r�r
r�rrfr6r5�	_unframerrirm�object�mark�stack�appendr�r��EOFErrorr��bytes_typesr�rr)rrir��keyZstopinstrrrr�s*					z_Unpickler.loadcCsG|j}|j}t|�d}x|||k	rB|d}q%W|S)Nrj)r:r9r^)rr:r9rrrr�markers		z_Unpickler.markercCstd��dS)Nz%unsupported persistent id encountered)r
)rr�rrr�persistent_load!sz_Unpickler.persistent_loadcCsO|jd�d}d|ko*tknsBtd|��n||_dS)Nrjrzunsupported pickle protocol: %d)rir�r�r�)rr�rrr�
load_proto&sz_Unpickler.load_protorcCsQtd|jd��\}|tjkr=td|��n|jj|�dS)Nz<Q�zframe size > sys.maxsize: %d)r
rir|rr�r7rp)rrorrrrp-sz_Unpickler.load_framecCs9|j�dd�jd�}|j|j|��dS)Nrjr�rk)rm�decoder;r@)rr�rrr�load_persid4sz_Unpickler.load_persidcCs)|jj�}|j|j|��dS)N)r:�popr;r@)rr�rrr�load_binpersid9sz_Unpickler.load_binpersidcCs|jd�dS)N)r;)rrrr�	load_none>sz_Unpickler.load_nonecCs|jd�dS)NF)r;)rrrr�
load_falseBsz_Unpickler.load_falsecCs|jd�dS)NT)r;)rrrr�	load_trueFsz_Unpickler.load_truecCsj|j�}|tdd�kr+d}n.|tdd�krJd}nt|d�}|j|�dS)NrjFTr)rmr�r�r�r;)rrc�valrrr�load_intJs		z_Unpickler.load_intcCs'|jtd|jd��d�dS)Nz<irr)r;r
ri)rrrr�load_binintUsz_Unpickler.load_binintcCs|j|jd�d�dS)Nrjr)r;ri)rrrr�load_binint1Ysz_Unpickler.load_binint1cCs'|jtd|jd��d�dS)Nz<Hr�r)r;r
ri)rrrr�load_binint2]sz_Unpickler.load_binint2cCsY|j�dd�}|r?|ddkr?|dd�}n|jt|d��dS)Nrjr*rrkrk�Lrk)rmr;r�)rrJrrr�	load_longasz_Unpickler.load_longcCs9|jd�d}|j|�}|jt|��dS)Nrjr)rir;r�)rrdrcrrr�
load_long1hsz_Unpickler.load_long1cCs\td|jd��\}|dkr6td��n|j|�}|jt|��dS)Nz<irrz#LONG pickle has negative byte count)r
rir
r;r�)rrdrcrrr�
load_long4ns
z_Unpickler.load_long4cCs'|jt|j�dd���dS)Nrjrk)r;r.rm)rrrr�
load_floatwsz_Unpickler.load_floatcCs'|jtd|jd��d�dS)Nz>drBr)r;r
ri)rrrr�
load_binfloat{sz_Unpickler.load_binfloatcCs-|jdkr|S|j|j|j�SdS)Nr�)r1rCr3)rrrrr�_decode_stringsz_Unpickler._decode_stringcCs�|j�dd�}t|�dkr_|d|dkr_|ddkr_|dd�}ntd��|j|jtj|�d��dS)	Nrjr�rs"'z)the STRING opcode argument must be quotedrkrkrk)rmr^r
r;rUr��
escape_decode)rrcrrr�load_string�s
6z_Unpickler.load_stringcCs_td|jd��\}|dkr6td��n|j|�}|j|j|��dS)Nz<irrz(BINSTRING pickle has negative byte count)r
rir
r;rU)rr^rcrrr�load_binstring�s
z_Unpickler.load_binstringcCsTtd|jd��\}|tkr:tdt��n|j|j|��dS)Nz<Irz2BINBYTES exceeds system's maximum size of %d bytes)r
rirr
r;)rr^rrr�
load_binbytes�s

z_Unpickler.load_binbytescCs*|jt|j�dd�d��dS)Nrjzraw-unicode-escaperk)r;r�rm)rrrr�load_unicode�sz_Unpickler.load_unicodecCs`td|jd��\}|tkr:tdt��n|jt|j|�dd��dS)Nz<Irz4BINUNICODE exceeds system's maximum size of %d byteszutf-8r�)r
rirr
r;r�)rr^rrr�load_binunicode�s

z_Unpickler.load_binunicodecCs`td|jd��\}|tkr:tdt��n|jt|j|�dd��dS)Nz<QrBz5BINUNICODE8 exceeds system's maximum size of %d byteszutf-8r�)r
rirr
r;r�)rr^rrr�load_binunicode8�s

z_Unpickler.load_binunicode8cCsTtd|jd��\}|tkr:tdt��n|j|j|��dS)Nz<QrBz3BINBYTES8 exceeds system's maximum size of %d bytes)r
rirr
r;)rr^rrr�load_binbytes8�s

z_Unpickler.load_binbytes8cCs<|jd�d}|j|�}|j|j|��dS)Nrjr)rir;rU)rr^rcrrr�load_short_binstring�sz_Unpickler.load_short_binstringcCs-|jd�d}|j|j|��dS)Nrjr)rir;)rr^rrr�load_short_binbytes�sz_Unpickler.load_short_binbytescCs9|jd�d}|jt|j|�dd��dS)Nrjrzutf-8r�)rir;r�)rr^rrr�load_short_binunicode�sz _Unpickler.load_short_binunicodecCs=|j�}t|j|dd��g|j|d�<dS)Nrj)r?r�r:)rrrrr�
load_tuple�sz_Unpickler.load_tuplecCs|jf�dS)N)r;)rrrr�load_empty_tuple�sz_Unpickler.load_empty_tuplecCs|jdf|jd<dS)Nrjrkrk)r:)rrrr�load_tuple1�sz_Unpickler.load_tuple1cCs.|jd|jdfg|jdd�<dS)Nr�rjr�rkr�)r:)rrrr�load_tuple2�sz_Unpickler.load_tuple2cCs8|jd|jd|jdfg|jdd�<dS)Nrr�rj���r�rkre)r:)rrrr�load_tuple3�sz_Unpickler.load_tuple3cCs|jg�dS)N)r;)rrrr�load_empty_list�sz_Unpickler.load_empty_listcCs|ji�dS)N)r;)rrrr�load_empty_dictionary�sz _Unpickler.load_empty_dictionarycCs|jt��dS)N)r;r)rrrr�load_empty_set�sz_Unpickler.load_empty_setcCs=|j�}t|j|dd��g|j|d�<dS)Nrj)r?rr:)rrrrr�load_frozenset�sz_Unpickler.load_frozensetcCs7|j�}|j|dd�g|j|d�<dS)Nrj)r?r:)rrrrr�	load_list�sz_Unpickler.load_listcsh|j�}|j|dd���fdd�tdt��d�D�}|g|j|d�<dS)Nrjcs%i|]}�|d�|�qS)rjr)rNr�)r~rr�
<dictcomp>�s	z(_Unpickler.load_dict.<locals>.<dictcomp>rr�)r?r:�ranger^)rr�dr)r~r�	load_dict�s
z_Unpickler.load_dictcCs�t|j|dd��}|j|d�=|sRt|t�sRt|d�r�y||�}Wq�tk
r�}z1td|jt|�ftj	�d��WYdd}~Xq�Xn|j
|�}|j|�dS)NrjZ__getinitargs__zin constructor for %s: %sr�)r�r:r�r�r�r�rr�r|�exc_infor�r;)r�klassrr�r�errrrr�_instantiates<z_Unpickler._instantiatecCsj|j�dd�jd�}|j�dd�jd�}|j||�}|j||j��dS)Nrjr�rkrk)rmrC�
find_classrsr?)rr�rwrqrrr�	load_instsz_Unpickler.load_instcCs6|j�}|jj|d�}|j||�dS)Nrj)r?r:rErs)rrrqrrr�load_objsz_Unpickler.load_objcCsA|jj�}|jj�}|j||�}|j|�dS)N)r:rEr�r;)rr�r�rvrrr�load_newobj#sz_Unpickler.load_newobjcCsS|jj�}|jj�}|jj�}|j|||�}|j|�dS)N)r:rEr�r;)rr�r�r�rvrrr�load_newobj_ex*s
z_Unpickler.load_newobj_excCsa|j�dd�jd�}|j�dd�jd�}|j||�}|j|�dS)Nrjzutf-8rkrk)rmrCrtr;)rr�rwrqrrr�load_global2sz_Unpickler.load_globalcCsn|jj�}|jj�}t|�tk	sBt|�tk	rQtd��n|j|j||��dS)NzSTACK_GLOBAL requires str)r:rEr�r�r
r;rt)rrwr�rrr�load_stack_global9s
$z_Unpickler.load_stack_globalcCs$|jd�d}|j|�dS)Nrjr)ri�
get_extension)rr*rrr�	load_ext1Asz_Unpickler.load_ext1cCs,td|jd��\}|j|�dS)Nz<Hr�)r
rir{)rr*rrr�	load_ext2Fsz_Unpickler.load_ext2cCs,td|jd��\}|j|�dS)Nz<ir)r
rir{)rr*rrr�	load_ext4Ksz_Unpickler.load_ext4cCs�g}tj||�}||k	r5|j|�dStj|�}|sx|dkretd��ntd|��n|j|�}|t|<|j|�dS)NrzEXT specifies code <= 0zunregistered extension code %d)rr�r;rr
r�rt)rr*Znilrvr>rrrr{Ps

z_Unpickler.get_extensioncCs�|jdkrk|jrk||ftjkrItj||f\}}qk|tjkrktj|}qknt|dd�ttj||d|jdk�S)Nrrrrxr)	r�r�r(ZNAME_MAPPINGZIMPORT_MAPPINGr ryr|r})rr�rwrrrrt`sz_Unpickler.find_classcCs3|j}|j�}|d}||�|d<dS)Nrjrkrk)r:rE)rr:r�r�rrr�load_reduceks	
z_Unpickler.load_reducecCs|jd=dS)Nrjrk)r:)rrrr�load_poprsz_Unpickler.load_popcCs |j�}|j|d�=dS)N)r?r:)rrrrr�
load_pop_markvsz_Unpickler.load_pop_markcCs|j|jd�dS)Nrjrk)r;r:)rrrr�load_dup{sz_Unpickler.load_dupcCs4t|j�dd��}|j|j|�dS)Nrjrk)r�rmr;r�)rr�rrr�load_getsz_Unpickler.load_getcCs+|jd�d}|j|j|�dS)Nrjr)rir;r�)rr�rrr�load_binget�sz_Unpickler.load_bingetcCs3td|jd��\}|j|j|�dS)Nz<Ir)r
rir;r�)rr�rrr�load_long_binget�sz_Unpickler.load_long_bingetcCsOt|j�dd��}|dkr7td��n|jd|j|<dS)Nrjrznegative PUT argumentrkrk)r�rmr�r:r�)rr�rrr�load_put�sz_Unpickler.load_putcCsF|jd�d}|dkr.td��n|jd|j|<dS)Nrjrznegative BINPUT argumentrk)rir�r:r�)rr�rrr�load_binput�sz_Unpickler.load_binputcCsNtd|jd��\}|tkr6td��n|jd|j|<dS)Nz<Irznegative LONG_BINPUT argumentrjrk)r
rirr�r:r�)rr�rrr�load_long_binput�sz_Unpickler.load_long_binputcCs$|j}|jd|t|�<dS)Nrjrk)r�r:r^)rr�rrr�load_memoize�s	z_Unpickler.load_memoizecCs0|j}|j�}|d}|j|�dS)Nrjrk)r:rEr;)rr:rr{rrr�load_append�s	
z_Unpickler.load_appendcCs�|j}|j�}||d}||dd�}t|t�rV|j|�n$|j}x|D]}||�qfW||d�=dS)Nrj)r:r?r�r{�extendr;)rr:r9Zlist_objr~r;rrrr�load_appends�s		
z_Unpickler.load_appendscCs9|j}|j�}|j�}|d}|||<dS)Nrjrk)r:rE)rr:rr>r/rrr�load_setitem�s
	
z_Unpickler.load_setitemcCsq|j}|j�}||d}x:t|dt|�d�D]}||d|||<q@W||d�=dS)Nrjr�)r:r?rmr^)rr:r9r/r�rrr�
load_setitems�s	#z_Unpickler.load_setitemscCs�|j}|j�}||d}||dd�}t|t�rV|j|�n$|j}x|D]}||�qfW||d�=dS)Nrj)r:r?r�r�update�add)rr:r9Zset_objr~r�rrrr�
load_additems�s		
z_Unpickler.load_additemsc
Cs"|j}|j�}|d}t|dd�}|dk	rK||�dSd}t|t�r�t|�dkr�|\}}n|r�|j}tj}xL|j	�D];\}}	t
|�tkr�|	|||�<q�|	||<q�Wn|rx-|j	�D]\}}	t|||	�q�WndS)Nrj�__setstate__r�rk)
r:rErur�r�r^�__dict__r|�internr~r�r��setattr)
rr:r�Zinst�setstateZ	slotstate�	inst_dictr�rrrrr�
load_build�s(	

!		z_Unpickler.load_buildcCs|j|j�dS)N)r;r9)rrrr�	load_mark�sz_Unpickler.load_markcCs|jj�}t|��dS)N)r:rEr)rrrrr�	load_stop�sz_Unpickler.load_stopN)�rrrrrr?r@r�rAr�rpr_rDr�rFr�rGr�rHr�rIr�rK�INTrLr�rMr�rNr�rPr�rQr�rRr�rSr�rTr�rUrW�STRINGrX�	BINSTRINGrYr�rZr�r[r�r\r�r]r�r^�SHORT_BINSTRINGr_r�r`r�rarrbrrc�TUPLE1rd�TUPLE2rf�TUPLE3rgrrhrrirrjrrkrrorrsru�INSTrv�OBJrwr�rxr�ryr'rzr&r|r#r}r$r~r%r{rtrr�r�r�r�rr��DUPr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r�r
r�rr�rr�rr�r�r�rr�r�rrrrr0�s	$%		r0r�TcCs t||d|�j|�dS)Nr�)r�r)rvr�r�r�rrr�_dumpsr�cCsMtj�}t||d|�j|�|j�}t|t�sIt�|S)Nr�)rUrVr�r�getvaluer�r=r�)rvr�r�rb�resrrr�_dumpss
r�r1r2r3r4cCs"t|d|d|d|�j�S)Nr�r1r3)r0r)r�r�r1r3rrr�_loadsr�cCsOt|t�rtd��ntj|�}t|d|d|d|�j�S)Nz%Can't load pickle from unicode stringr�r1r3)r�r�r�rUrVr0r)�sr�r1r3r�rrr�_loadss
r�)	rrr
rrrrrrcCsddl}|j�S)Nr)�doctestZtestmod)r�rrr�_test(sr�rzZdescriptionz$display contents of the pickle files�pickle_filer�Zbr�nargs�*�helpzthe pickle filez-tz--test�action�
store_truezrun self-test suitez-vz)run verbosely; only affects self-test run)�r�typesr�copyregrrrr�	itertoolsrr|rZstructr	r
rLrUr�r(�__all__r��	bytearrayr=Zformat_versionZcompatible_formatsr�r��	Exceptionrrr
rZorg.python.corer r!rr�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r�r'rrr
r�r�r�r�rrr�r�r�r�rrrrr�r�r�r�r�r#r$r%r�r�r�r�r�r�r�rr�r�r�r�r�rrrr�r&r�r_r��dirrQrfryr�r�r�r�r0r�r�r�r��_picklerrrrrrr�r�argparse�ArgumentParser�parser�add_argumentZFileType�
parse_argsr�Ztestr�Z
print_help�pprintrbrvrrrr�<module>s"	

$*��t��5D
#		
	




?>