Mini Shell

Direktori : /opt/cppython/lib/python3.8/test/__pycache__/
Upload File :
Current File : //opt/cppython/lib/python3.8/test/__pycache__/pickletester.cpython-38.pyc

U

��eg��,@szddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlmZzddlZWnek
r�dZYnXddlmZddlmZmZmZmZmZmZmZmZm Z m!Z!ddlm"Z"ze!��ddl#Z$W5QRXWnek
�r6dZ$YnXe
�%ej&dkd�Z'e(ej)d	�Z*d
d�Z+dd
�Z,dd�Z-Gdd�dej.�Z/Gdd�de0�Z1Gdd�d�Z2Gdd�d�Z3Gdd�de3�Z4Gdd�de3�Z5Gdd�d�Z6Gdd�d�Z7ddl8Z8e3e8_3d e3_9e4e8_4d e4_9e5e8_5d e5_9Gd!d"�d"e:�Z;Gd#d$�d$e3�Z<Gd%d&�d&e=�Z>Gd'd(�d(e0e>d)�Z?Gd*d+�d+e=�Z@d,d-�ZAGd.d/�d/eB�ZCGd0d1�d1eD�ZEedk	�r�Gd2d3�d3�ZFd4ZGd5ZHd6ZId7ZJd8ZKd9ZLd:ZMd;ZNd<ZOd=ZPd>ZQd?ZRd@ZSdAZTeUeVeWeXeYeZe[e\e]e^e_e`eaebeecedeeefegeheiejekelemeneoepeqereseteuevewexeyeze{e|e}e~ef,Z�dBZ�dCZ�dDdE�Z�GdFdG�dGe
j��Z�GdHdI�dIe
j��Z�GdJdK�dKe
j��Z�GdLdM�dMe0�Z�GdNdO�dOe0�Z�GdPdQ�dQe0�Z�GdRdS�dSe0�Z�GdTdU�dUe0�Z�GdVdW�dWe0�Z�GdXdY�dYe0�Z�GdZd[�d[e0�Z�Gd\d]�d]e:�Z�Gd^d_�d_e��Z�Gd`da�dae��Z�Gdbdc�dce��Z�Gddde�dee��Z�Gdfdg�dge��Z�Gdhdi�die��Z�Gdjdk�dke��Z�Gdldm�dme��Z�Gdndo�doe��Z�e�e�e�e�e�e�e�e�e�e�g
Z�Gdpdq�dqe��Z�Gdrds�dse:�a�Gdtdu�dut��Z�Gdvdw�dwt��Z�Gdxdy�dy�Z�Gdzd{�d{e
j��Z�Gd|d}�d}e
j��Z�Gd~d�de
j��Z�Gd�d��d�e
j��Z�d�Z�Gd�d��d�e0�Z�Gd�d��d�e0�Z�d�d��Z�Gd�d��d��Z�Gd�d��d�e
j��Z�Gd�d��d�e
j��Z�e�d k�rvdd�lm�Z�e��Z�e(ej)d	�D]�Z�e��e�e��Z�e�d���e���e(de�e��d��D](Z�eBe�e�e�d���Z�e�d���e����qe�d��e��e�d���e���e�d���e���e�e��e�d��e���q�dS)��N)�dedent)�SimpleCookie)�support)
�
TestFailed�TESTFN�run_with_locale�
no_tracing�_2G�_4G�
bigmemtest�reap_threads�forget�save_restore_warnings_filters)�bytes_typeslz(test is only meaningful on 32-bit builds�cCs0t�|�D] \}}}|j|�d�kr
dSq
dS)N�latin-1TF��pickletools�genops�code�decode)r�pickle�op�dummy�r�0/opt/cppython/lib/python3.8/test/pickletester.py�opcode_in_pickle5srcCs6d}t�|�D]"\}}}|j|�d�kr|d7}q|S)Nrrrr)rr�nrrrrr�count_opcode<s

rcCs|S�Nr��xrrr�identityDsr"c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�UnseekableIOcGst�dSr)�NotImplementedError��self�argsrrr�peekIszUnseekableIO.peekcCsdS)NFr�r&rrr�seekableLszUnseekableIO.seekablecGs
tj�dSr��io�UnsupportedOperationr%rrr�seekOszUnseekableIO.seekcCs
tj�dSrr+r)rrr�tellRszUnseekableIO.tellN)�__name__�
__module__�__qualname__r(r*r.r/rrrrr#Hsr#c@seZdZdZdd�ZdS)�	MinimalIOz=
    A file-like object that doesn't support readinto().
    cGs8tj|�|_|jj|_|jj|_|jj|_|jj|_dSr)r,�BytesIOZ_bio�getvalue�read�readline�writer%rrr�__init__Zs



zMinimalIO.__init__N)r0r1r2�__doc__r9rrrrr3Vsr3c@seZdZdd�Zdd�ZdS)�ExtensionSavercCsB||_|tjkr8tj||_t�|jd|jd|�nd|_dS�Nrr)r�copyreg�_inverted_registry�pair�remove_extension)r&rrrrr9os

zExtensionSaver.__init__cCsX|j}tj�|�}|dk	r0t�|d|d|�|j}|dk	rTt�|d|d|�dSr<)rr=r>�getr@r?�
add_extension)r&rZcurpairr?rrr�restorexszExtensionSaver.restoreN)r0r1r2r9rCrrrrr;ls	r;c@seZdZdd�ZdS)�CcCs|j|jkSr)�__dict__�r&�otherrrr�__eq__�szC.__eq__N)r0r1r2rHrrrrrD�srDc@seZdZdd�ZdS)�DcCsdSrr)r&�argrrrr9�sz
D.__init__N�r0r1r2r9rrrrrI�srIc@seZdZdd�ZdS)�EcCsdS�Nrrr)rrr�__getinitargs__�szE.__getinitargs__N)r0r1r2rNrrrrrL�srLc@seZdZdS)�ObjectN�r0r1r2rrrrrO�srOc@seZdZdd�Zdd�ZdS)�KcCs
||_dSr)�value)r&rRrrrr9�sz
K.__init__cCst|jffSr)rQrRr)rrr�
__reduce__�szK.__reduce__N)r0r1r2r9rSrrrrrQ�srQ�__main__c@seZdZdd�ZdS)�myintcCst|�|_dSr��str)r&r!rrrr9�szmyint.__init__NrKrrrrrU�srUc@seZdZdd�Zdd�ZdS)�initargcCs||_||_dSr��a�b)r&rZr[rrrr9�szinitarg.__init__cCs|j|jfSrrYr)rrrrN�szinitarg.__getinitargs__N)r0r1r2r9rNrrrrrX�srXc@seZdZdS)�	metaclassNrPrrrrr\�sr\c@seZdZdS)�
use_metaclassNrPrrrrr]�sr])r\c@seZdZdd�Zdd�ZdS)�pickling_metaclasscCst|�t|�ko|j|jkSr)�type�reduce_argsrFrrrrH�s
�zpickling_metaclass.__eq__cCs
t|jfSr)�create_dynamic_classr`r)rrrrS�szpickling_metaclass.__reduce__N)r0r1r2rHrSrrrrr^�sr^cCst||t��}||f|_|Sr)r^�dictr`)�name�bases�resultrrrra�s
rac@s<eZdZdZdZdZdZdd�Zdd�ZeZ	e
dd��ZdS)	�
ZeroCopyBytesTcCs8|dkr t|�jt�|�fdfSt|�jt|�ffSdS�N��r_�_reconstructr�PickleBuffer�bytes�r&�protocolrrr�
__reduce_ex__�szZeroCopyBytes.__reduce_ex__cCsd�|jjt|��S�Nz{}({!r})��format�	__class__r0rlr)rrr�__repr__�szZeroCopyBytes.__repr__c
CsNt|��<}|j}t|�|kr,|W5QR�S||�W5QR�SW5QRXdSr��
memoryview�objr_��clsrw�mrrrrj�s

zZeroCopyBytes._reconstructN�r0r1r2�readonly�c_contiguous�f_contiguous�zero_copy_reconstructrort�__str__�classmethodrjrrrrrf�srfc@s<eZdZdZdZdZdZdd�Zdd�ZeZ	e
dd��Zd	S)
�ZeroCopyBytearrayFTcCs8|dkr t|�jt�|�fdfSt|�jt|�ffSdSrgrirmrrrro�szZeroCopyBytearray.__reduce_ex__cCsd�|jjt|��Srprqr)rrrrt�szZeroCopyBytearray.__repr__c
CsNt|��<}|j}t|�|kr,|W5QR�S||�W5QR�SW5QRXdSrrurxrrrrj�s

zZeroCopyBytearray._reconstructNr{rrrrr��sr�c@speZdZdZdd�Zdd�Zedd��Zedd	��Zed
d��Z	dd
�Z
dd�Zdd�Zdd�Z
edd��ZdS)�PicklableNDArrayFcOstj||�|_dSr)�_testbufferZndarray�array�r&r'�kwargsrrrr9szPicklableNDArray.__init__cCs"t|�}|�|�}|j||_|Sr)r_�__new__r�)r&�idxry�newrrr�__getitem__s
zPicklableNDArray.__getitem__cCs|jjSr)r�r|r)rrrr|szPicklableNDArray.readonlycCs|jjSr)r�r}r)rrrr}szPicklableNDArray.c_contiguouscCs|jjSr)r�r~r)rrrr~szPicklableNDArray.f_contiguouscCsbt|t�stS|jj|jjko`|jj|jjko`|jj|jjko`|jj|jjko`|j��|j��kSr)	�
isinstancer��NotImplementedr�rr�shape�stridesr|�tobytesrFrrrrHs
����zPicklableNDArray.__eq__cCst|t�stS||kSr)r�r�r�rFrrr�__ne__!s
zPicklableNDArray.__ne__cCs.t|��d|jj�d|jj�d|j���d�S)Nz(shape=z	,strides=z, bytes=�))r_r�r�r�r�r)rrrrt&szPicklableNDArray.__repr__c
Cs�|jjstd��|jj|jj|jj|jr,dntjd�}t	�
|j�}|dkr\t|�j||ffS|�
��$}t|�j|��|ffW5QR�SQRXdS)Nz>Reconstructing a non-contiguous ndarray does not seem possibler)r�r�rr�flagsrh)r��
contiguousr$r�r�rrr|r��ND_WRITABLErrkr_rj�rawr�)r&rnZndarray_kwargs�pbrzrrrro+s"
��

�zPicklableNDArray.__reduce_ex__c	Cs,t|��}t|���}W5QRX||f|�Sr)rv�listr�)ryrwr�rz�itemsrrrrj>s
zPicklableNDArray._reconstructN)r0r1r2rr9r��propertyr|r}r~rHr�rtror�rjrrrrr��s


	r�s;(lp0
L0L
aL1L
aF2.0
ac__builtin__
complex
p1
(F3.0
F0.0
tp2
Rp3
aL1L
aL-1L
aL255L
aL-255L
aL-256L
aL65535L
aL-65535L
aL-65536L
aL2147483647L
aL-2147483647L
aL-2147483648L
a(Vabc
p4
g4
ccopy_reg
_reconstructor
p5
(c__main__
C
p6
c__builtin__
object
p7
Ntp8
Rp9
(dp10
Vfoo
p11
L1L
sVbar
p12
L2L
sbg9
tp13
ag13
aL5L
a.an    0: (    MARK
    1: l        LIST       (MARK at 0)
    2: p    PUT        0
    5: L    LONG       0
    9: a    APPEND
   10: L    LONG       1
   14: a    APPEND
   15: F    FLOAT      2.0
   20: a    APPEND
   21: c    GLOBAL     '__builtin__ complex'
   42: p    PUT        1
   45: (    MARK
   46: F        FLOAT      3.0
   51: F        FLOAT      0.0
   56: t        TUPLE      (MARK at 45)
   57: p    PUT        2
   60: R    REDUCE
   61: p    PUT        3
   64: a    APPEND
   65: L    LONG       1
   69: a    APPEND
   70: L    LONG       -1
   75: a    APPEND
   76: L    LONG       255
   82: a    APPEND
   83: L    LONG       -255
   90: a    APPEND
   91: L    LONG       -256
   98: a    APPEND
   99: L    LONG       65535
  107: a    APPEND
  108: L    LONG       -65535
  117: a    APPEND
  118: L    LONG       -65536
  127: a    APPEND
  128: L    LONG       2147483647
  141: a    APPEND
  142: L    LONG       -2147483647
  156: a    APPEND
  157: L    LONG       -2147483648
  171: a    APPEND
  172: (    MARK
  173: V        UNICODE    'abc'
  178: p        PUT        4
  181: g        GET        4
  184: c        GLOBAL     'copy_reg _reconstructor'
  209: p        PUT        5
  212: (        MARK
  213: c            GLOBAL     '__main__ C'
  225: p            PUT        6
  228: c            GLOBAL     '__builtin__ object'
  248: p            PUT        7
  251: N            NONE
  252: t            TUPLE      (MARK at 212)
  253: p        PUT        8
  256: R        REDUCE
  257: p        PUT        9
  260: (        MARK
  261: d            DICT       (MARK at 260)
  262: p        PUT        10
  266: V        UNICODE    'foo'
  271: p        PUT        11
  275: L        LONG       1
  279: s        SETITEM
  280: V        UNICODE    'bar'
  285: p        PUT        12
  289: L        LONG       2
  293: s        SETITEM
  294: b        BUILD
  295: g        GET        9
  298: t        TUPLE      (MARK at 172)
  299: p    PUT        13
  303: a    APPEND
  304: g    GET        13
  308: a    APPEND
  309: L    LONG       5
  313: a    APPEND
  314: .    STOP
highest protocol among opcodes = 0
s�]q(KKG@c__builtin__
complex
q(G@GtqRqKJ����K�J���J���M��J��J��J���J�J�(Xabcqhccopy_reg
_reconstructor
q(c__main__
C
qc__builtin__
object
qNtqRq	}q
(XfooqKXbarqKubh	tq
h
Ke.a    0: ]    EMPTY_LIST
    1: q    BINPUT     0
    3: (    MARK
    4: K        BININT1    0
    6: K        BININT1    1
    8: G        BINFLOAT   2.0
   17: c        GLOBAL     '__builtin__ complex'
   38: q        BINPUT     1
   40: (        MARK
   41: G            BINFLOAT   3.0
   50: G            BINFLOAT   0.0
   59: t            TUPLE      (MARK at 40)
   60: q        BINPUT     2
   62: R        REDUCE
   63: q        BINPUT     3
   65: K        BININT1    1
   67: J        BININT     -1
   72: K        BININT1    255
   74: J        BININT     -255
   79: J        BININT     -256
   84: M        BININT2    65535
   87: J        BININT     -65535
   92: J        BININT     -65536
   97: J        BININT     2147483647
  102: J        BININT     -2147483647
  107: J        BININT     -2147483648
  112: (        MARK
  113: X            BINUNICODE 'abc'
  121: q            BINPUT     4
  123: h            BINGET     4
  125: c            GLOBAL     'copy_reg _reconstructor'
  150: q            BINPUT     5
  152: (            MARK
  153: c                GLOBAL     '__main__ C'
  165: q                BINPUT     6
  167: c                GLOBAL     '__builtin__ object'
  187: q                BINPUT     7
  189: N                NONE
  190: t                TUPLE      (MARK at 152)
  191: q            BINPUT     8
  193: R            REDUCE
  194: q            BINPUT     9
  196: }            EMPTY_DICT
  197: q            BINPUT     10
  199: (            MARK
  200: X                BINUNICODE 'foo'
  208: q                BINPUT     11
  210: K                BININT1    1
  212: X                BINUNICODE 'bar'
  220: q                BINPUT     12
  222: K                BININT1    2
  224: u                SETITEMS   (MARK at 199)
  225: b            BUILD
  226: h            BINGET     9
  228: t            TUPLE      (MARK at 112)
  229: q        BINPUT     13
  231: h        BINGET     13
  233: K        BININT1    5
  235: e        APPENDS    (MARK at 3)
  236: .    STOP
highest protocol among opcodes = 1
s��]q(KKG@c__builtin__
complex
qG@G�qRqKJ����K�J���J���M��J��J��J���J�J�(Xabcqhc__main__
C
q)�q}q(XfooqKXbarq	Kubhtq
h
Ke.u�    0: € PROTO      2
    2: ]    EMPTY_LIST
    3: q    BINPUT     0
    5: (    MARK
    6: K        BININT1    0
    8: K        BININT1    1
   10: G        BINFLOAT   2.0
   19: c        GLOBAL     '__builtin__ complex'
   40: q        BINPUT     1
   42: G        BINFLOAT   3.0
   51: G        BINFLOAT   0.0
   60: †     TUPLE2
   61: q        BINPUT     2
   63: R        REDUCE
   64: q        BINPUT     3
   66: K        BININT1    1
   68: J        BININT     -1
   73: K        BININT1    255
   75: J        BININT     -255
   80: J        BININT     -256
   85: M        BININT2    65535
   88: J        BININT     -65535
   93: J        BININT     -65536
   98: J        BININT     2147483647
  103: J        BININT     -2147483647
  108: J        BININT     -2147483648
  113: (        MARK
  114: X            BINUNICODE 'abc'
  122: q            BINPUT     4
  124: h            BINGET     4
  126: c            GLOBAL     '__main__ C'
  138: q            BINPUT     5
  140: )            EMPTY_TUPLE
  141:          NEWOBJ
  142: q            BINPUT     6
  144: }            EMPTY_DICT
  145: q            BINPUT     7
  147: (            MARK
  148: X                BINUNICODE 'foo'
  156: q                BINPUT     8
  158: K                BININT1    1
  160: X                BINUNICODE 'bar'
  168: q                BINPUT     9
  170: K                BININT1    2
  172: u                SETITEMS   (MARK at 147)
  173: b            BUILD
  174: h            BINGET     6
  176: t            TUPLE      (MARK at 113)
  177: q        BINPUT     10
  179: h        BINGET     10
  181: K        BININT1    5
  183: e        APPENDS    (MARK at 5)
  184: .    STOP
highest protocol among opcodes = 2
s��]q(KKG@cbuiltins
complex
qG@G�qRqKJ����K�J���J���M��J��J��J���J�J�(Xabcqhc__main__
C
q)�q}q(XbarqKXfooq	Kubhtq
h
Ke.u�    0: € PROTO      3
    2: ]    EMPTY_LIST
    3: q    BINPUT     0
    5: (    MARK
    6: K        BININT1    0
    8: K        BININT1    1
   10: G        BINFLOAT   2.0
   19: c        GLOBAL     'builtins complex'
   37: q        BINPUT     1
   39: G        BINFLOAT   3.0
   48: G        BINFLOAT   0.0
   57: †     TUPLE2
   58: q        BINPUT     2
   60: R        REDUCE
   61: q        BINPUT     3
   63: K        BININT1    1
   65: J        BININT     -1
   70: K        BININT1    255
   72: J        BININT     -255
   77: J        BININT     -256
   82: M        BININT2    65535
   85: J        BININT     -65535
   90: J        BININT     -65536
   95: J        BININT     2147483647
  100: J        BININT     -2147483647
  105: J        BININT     -2147483648
  110: (        MARK
  111: X            BINUNICODE 'abc'
  119: q            BINPUT     4
  121: h            BINGET     4
  123: c            GLOBAL     '__main__ C'
  135: q            BINPUT     5
  137: )            EMPTY_TUPLE
  138:          NEWOBJ
  139: q            BINPUT     6
  141: }            EMPTY_DICT
  142: q            BINPUT     7
  144: (            MARK
  145: X                BINUNICODE 'bar'
  153: q                BINPUT     8
  155: K                BININT1    2
  157: X                BINUNICODE 'foo'
  165: q                BINPUT     9
  167: K                BININT1    1
  169: u                SETITEMS   (MARK at 144)
  170: b            BUILD
  171: h            BINGET     6
  173: t            TUPLE      (MARK at 110)
  174: q        BINPUT     10
  176: h        BINGET     10
  178: K        BININT1    5
  180: e        APPENDS    (MARK at 5)
  181: .    STOP
highest protocol among opcodes = 2
s����]�(KKG@�builtins��complex���G@G��R�KJ����K�J���J���M��J��J��J���J�J�(�abc�h�__main__��C���)��}�(�bar�K�foo�Kubh
t�hKe.u�    0: € PROTO      4
    2: • FRAME      168
   11: ]    EMPTY_LIST
   12: ” MEMOIZE
   13: (    MARK
   14: K        BININT1    0
   16: K        BININT1    1
   18: G        BINFLOAT   2.0
   27: Œ     SHORT_BINUNICODE 'builtins'
   37: ”     MEMOIZE
   38: Œ     SHORT_BINUNICODE 'complex'
   47: ”     MEMOIZE
   48: “     STACK_GLOBAL
   49: ”     MEMOIZE
   50: G        BINFLOAT   3.0
   59: G        BINFLOAT   0.0
   68: †     TUPLE2
   69: ”     MEMOIZE
   70: R        REDUCE
   71: ”     MEMOIZE
   72: K        BININT1    1
   74: J        BININT     -1
   79: K        BININT1    255
   81: J        BININT     -255
   86: J        BININT     -256
   91: M        BININT2    65535
   94: J        BININT     -65535
   99: J        BININT     -65536
  104: J        BININT     2147483647
  109: J        BININT     -2147483647
  114: J        BININT     -2147483648
  119: (        MARK
  120: Œ         SHORT_BINUNICODE 'abc'
  125: ”         MEMOIZE
  126: h            BINGET     6
  128: Œ         SHORT_BINUNICODE '__main__'
  138: ”         MEMOIZE
  139: Œ         SHORT_BINUNICODE 'C'
  142: ”         MEMOIZE
  143: “         STACK_GLOBAL
  144: ”         MEMOIZE
  145: )            EMPTY_TUPLE
  146:          NEWOBJ
  147: ”         MEMOIZE
  148: }            EMPTY_DICT
  149: ”         MEMOIZE
  150: (            MARK
  151: Œ             SHORT_BINUNICODE 'bar'
  156: ”             MEMOIZE
  157: K                BININT1    2
  159: Œ             SHORT_BINUNICODE 'foo'
  164: ”             MEMOIZE
  165: K                BININT1    1
  167: u                SETITEMS   (MARK at 150)
  168: b            BUILD
  169: h            BINGET     10
  171: t            TUPLE      (MARK at 119)
  172: ”     MEMOIZE
  173: h        BINGET     14
  175: K        BININT1    5
  177: e        APPENDS    (MARK at 13)
  178: .    STOP
highest protocol among opcodes = 4
s%�c__builtin__
set
q]q(KKe�qRq.s%�c__builtin__
xrange
qKKK�qRq.s��cCookie
SimpleCookie
q)�qUkeyqcCookie
Morsel
q)�q(UcommentqUqUdomainqhUsecureqhUexpiresq	hUmax-ageq
hUversionqhUpathqhUhttponlyq
hu}q(Ucoded_valueqUvalueqhhhhubs}qb.s"�c__builtin__
set
q]qKa�qRq.s�cexceptions
?
q)Rq.sI�cexceptions
UnicodeEncodeError
q(UasciiqXfooqKKUbadqtqRq.cCs�t�}d|_d|_ddddg}d}d}d}|�dd	|||d|||d|||dg�d
d
||f}|�|�|�|�|�d�|S)Nr�rg@y@��������abcrh)rD�foo�bar�extend�append)�cr!Zuint1maxZuint2maxZint4max�yrrr�create_data&s.�


r�c@s�eZdZe�Zd\dd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zed$d%��Zed&d'��Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zed2d3��Zed4d5��Zed6d7��Z d8d9�Z!d:d;�Z"d<d=�Z#d>d?�Z$d@dA�Z%edBdC��Z&dDdE�Z'dFdG�Z(dHdI�Z)dJdK�Z*dLdM�Z+dNdO�Z,dPdQ�Z-dRdS�Z.dTdU�Z/dVdW�Z0dXdY�Z1e2dZd[��Z3dS)]�AbstractUnpickleTestsNcCs�|dkrd�||�}|j|||d�|jt|�t|�|d�t|d�rn|j|j|j|d�|j|j|j|d�t|d�r�|j|j	|j	|d�|j	D]@}|jt||�t||�|d�|jt
||d�t
||d�|d�q�dS)zKUtility method to verify if two objects are copies of each others.
        Nz{!r} is not a copy of {!r})�msgrE�	__slots__)rr�assertEqual�assertIsr_�hasattrZassertDictEqualrE�assertIsNotZassertListEqualr��getattr)r&rwZobjcopyr�Zslotrrr�assert_is_copy@s&


�
�z$AbstractUnpickleTests.assert_is_copycCs�|j|d��p|�|��Zz|�|�WnDtk
rl}z&tjdkrZtd||jj|f��W5d}~XYnXW5QRXW5QRXdS)N)�datarz%-32r - %s: %s)	�subTest�assertRaises�loads�
BaseExceptionr�verbose�printrsr0)r&�errorsr��excrrr�check_unpickling_errorRs�
�z,AbstractUnpickleTests.check_unpickling_errorcCs|�|j|�t��dSr)r��	_testdatar��DATA0r)rrr�test_load_from_data0]sz*AbstractUnpickleTests.test_load_from_data0cCs|�|j|�t��dSr)r�r�r��DATA1r)rrr�test_load_from_data1`sz*AbstractUnpickleTests.test_load_from_data1cCs|�|j|�t��dSr)r�r�r��DATA2r)rrr�test_load_from_data2csz*AbstractUnpickleTests.test_load_from_data2cCs|�|j|�t��dSr)r�r�r��DATA3r)rrr�test_load_from_data3fsz*AbstractUnpickleTests.test_load_from_data3cCs|�|j|�t��dSr)r�r�r��DATA4r)rrr�test_load_from_data4isz*AbstractUnpickleTests.test_load_from_data4cCs�tdftdftdffD]z\}}|j�d�}d�d|�}|�||�|�|��d�d|�}|�||�|�|��d�d|�}|�||�|�|��qdS)Nrr �asciis(i__main__
X
p0
(dp1
b.�Xs(c__main__
X
qoq}qb.s�(c__main__
X
qoq}qb.)rDrIrLr0�encode�replacer�r�)r&�Xr'ZxnameZpickle0Zpickle1Zpickle2rrr�test_load_classic_instancels"���z0AbstractUnpickleTests.test_load_classic_instancecCsVd}dt|��d�d}|�|�}|�||�dt|��d�d}|�t|�dS)Nl�����Ir��
.sJUNK
.)rWr�r�r�r��
ValueError)r&Zmaxint64r��gotrrr�
test_maxint64�s
z#AbstractUnpickleTests.test_maxint64cCsX|�t�}|�|tddg��|�t�}|�t|�ttd���|�t|�ttd���|�t�}|�t|�t	�|�t|�
��dg�|�|djd�tD]2}t
�d|j�d��}|�|�}|�t|�|�q�|�t
�dd	��}|�t|�t�|�t�}|�t|�t�|�|jd
�|�|jd�|�|jd�|�|jd�|�|jd�dS)Nrr�rrh�keyrR�?r��
StandardErrorr�Zbad)r��DATA_SETr��set�DATA_XRANGEr_�ranger��DATA_COOKIEr�keysrR�python2_exceptions_without_args�exception_pickler�r0r�r��	Exception�
DATA_UEERR�UnicodeEncodeError�object�encoding�start�end�reason)r&�loadedr�r�rrr�test_unpickle_from_2x�s,




z+AbstractUnpickleTests.test_unpickle_from_2xcCsF|�|jddd�d�|�|jddd�d�|�|jddd�d�dS)NsS'a\x00\xa0'
.rl�r�sa�sUa�.s�Ua�.�r�r�r)rrr�test_load_python2_str_as_bytes�s
��
��
��z4AbstractUnpickleTests.test_load_python2_str_as_bytescCsF|�|jddd�d�|�|jddd�d�|�|jddd�d�dS)Ns	V\u03c0
.rlr�uπsXπ.s
�Xπ.r�r)rrr� test_load_python2_unicode_as_str�s
��
��
��z6AbstractUnpickleTests.test_load_python2_unicode_as_strcCs2|�|jtjt�dd�dtjdd�d�dS)N�<Ii,s,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrlr�)r�r�r�	BINSTRING�struct�pack�STOPr)rrr�#test_load_long_python2_str_as_bytes�s
�����z9AbstractUnpickleTests.test_load_long_python2_str_as_bytescCs\|�|�d��|�|�d�d�|�|�d�d�|�|�d�d�|�|�d�d�dS)NsN.s�.Ts�.FsI01
.sI00
.)�assertIsNoner�r�r)rrr�test_constants�s
z$AbstractUnpickleTests.test_constantscCs|jddd�}|�|d�dS)Ns�Uq.zkoi8-rr��)r�r�)r&�emptyrrr�test_empty_bytestring�sz+AbstractUnpickleTests.test_empty_bytestringcCsd}|�|�|�d�dS)Ns	�C€.�€r��r&�dumpedrrr�test_short_binbytes�sz)AbstractUnpickleTests.test_short_binbytescCsd}|�|�|�d�dS)Ns�B€.r�r�r�rrr�
test_binbytes�sz#AbstractUnpickleTests.test_binbytescCsd}|�tjtf|�dS)Ns
�B����xyzq.�r�r�UnpicklingError�
OverflowErrorr�rrr�test_negative_32b_binbytes�s�z0AbstractUnpickleTests.test_negative_32b_binbytescCsd}|�tjtf|�dS)Ns
�X����xyzq.r�r�rrr�test_negative_32b_binunicodes�z2AbstractUnpickleTests.test_negative_32b_binunicodecCsd}|�|�|�d�dS)Ns	��€.�€r�r�rrr�test_short_binunicodesz+AbstractUnpickleTests.test_short_binunicodecCs&|�td�|�ddg|�d��dS)Nsg0
p0)�ds((Kdtp0
hl.)))r��KeyErrorr�r�r)rrr�
test_misc_gets
�z#AbstractUnpickleTests.test_misc_getcCsd}|�|�|�d�dS)Ns��€.r�r�r�rrr�test_binbytes8sz$AbstractUnpickleTests.test_binbytes8cCsd}|�|�|�d�dS)Ns��€.r�r�r�rrr�test_binunicode8sz&AbstractUnpickleTests.test_binunicode8cCsd}|�|�|�td��dS)Ns��xxx.sxxx)r�r��	bytearrayr�rrr�test_bytearray8sz%AbstractUnpickleTests.test_bytearray8cCsd}|�tjtf|�dS)Ns��€.r�r�rrr�test_large_32b_binbytes8!s�z.AbstractUnpickleTests.test_large_32b_binbytes8cCsd}|�tjtf|�dS)Ns��€.r�r�rrr�test_large_32b_bytearray8's�z/AbstractUnpickleTests.test_large_32b_bytearray8cCsd}|�tjtf|�dS)Ns��€.r�r�rrr�test_large_32b_binunicode8-s�z0AbstractUnpickleTests.test_large_32b_binunicode8cCs8d}|�|�}|�|gfd�|�|d|d�dS)Ns((lp100000
g100000
t.r�rr�r�r�r��r&�pickled�	unpickledrrr�test_get3s
zAbstractUnpickleTests.test_getcCs8d}|�|�}|�|gfd�|�|d|d�dS)Ns(]q�h�t.r�rrrrrrr�test_binget9s
z!AbstractUnpickleTests.test_bingetcCs8d}|�|�}|�|gfd�|�|d|d�dS)Ns(]rjt.r�rrrrrrr�test_long_binget?s
z&AbstractUnpickleTests.test_long_bingetcCs8d}|�|�}|�|gfd�|�|d|d�dS)Ns((l2t.r�rrrrrrr�test_dupEs
zAbstractUnpickleTests.test_dupcCsd}|�t|�dS)NsVa
p-1
.�r�r�r�rrr�test_negative_putKsz'AbstractUnpickleTests.test_negative_putcCsd}|�t|�dS)Ns�Xar����.rr�rrr�test_negative_32b_binputPsz.AbstractUnpickleTests.test_negative_32b_binputcCs|�td�dS)NsS'\'
.rr)rrr�test_badly_escaped_stringVsz/AbstractUnpickleTests.test_badly_escaped_stringc
Cs:ddddddddd	d
ddd
g
}|D]}|�tj|�q"dS)NsS'
.sS"
.sS' 
.sS" 
.sS'"
.sS"'
.sS' ' 
.sS" " 
.sS ''
.sS ""
.sS 
.sS
.sS.)r�rr��r&Z
badpickles�prrr�test_badly_quoted_stringYs �
z.AbstractUnpickleTests.test_badly_quoted_stringcCs0ddddg}|D]\}}|�|�|�|�qdS)N)sS''
.r�)sS""
.r�)sS"\n"
.�
)sS'\n'
.rr�)r&Zgoodpicklesr�expectedrrr�test_correctly_quoted_stringks�z2AbstractUnpickleTests.test_correctly_quoted_stringcCsd}|�|�|�d�dS)Ns��I42
.�*r�)r&r
rrr�test_frame_readlinessz)AbstractUnpickleTests.test_frame_readlinec	Csd}|�|�}|�t|�t�|�|tdd��|�t|�ddddddg�d	}|�|�|�tj�d
}|�|�|�tj	�dD]:}d|d
}|�|�}|�t|�t
�|�t|�d�q�dD]B}d|d}|�|�}|�t|�tj
�|�|t�
ddi��q�dS)Ns�c__builtin__
xrange
KKK�R.r�r���rh�s�c__builtin__
reduce
.s�cwhichdb
whichdb
.)s	Exceptionr�s�cexceptions
s	
Uugh�R.Zugh)sUserDictsIterableUserDicts
�(cUserDict
s
o}Udata}KKssb.)r�r�r_r�r�r��	functools�reduce�dbm�whichdbr�rW�collections�UserDict)r&r
rrcrrr�test_compat_unpickle{s*

�
z*AbstractUnpickleTests.test_compat_unpicklecCs.|�|�d�d�|�td�|�td�dS)Nscbuiltins
int
)R.rsN)R.scbuiltins
int
NR.)r�r�r��	TypeErrorr)rrr�test_bad_reduce�sz%AbstractUnpickleTests.test_bad_reducecCs8tjtf}|�|�d�d�|�|d�|�|d�dS)Nscbuiltins
int
)�.rscbuiltins
len
)�.scbuiltins
int
N�.�rr�r*r�r�r��r&�errorrrr�test_bad_newobj�s
z%AbstractUnpickleTests.test_bad_newobjcCsDtjtf}|�|�d�d�|�|d�|�|d�|�|d�dS)Nscbuiltins
int
)}�.rscbuiltins
len
)}�.scbuiltins
int
N}�.scbuiltins
int
)N�.r,r-rrr�test_bad_newobj_ex�s

z(AbstractUnpickleTests.test_bad_newobj_exc,Csxddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g,}|D]}|�|j|�q`dS)-N�.�0�1�2s(2�Rs)R�asNa�bsNb�d�es(esibuiltins
list
�l�os(osp1
sqsr�ssNssNNs�t�us(us}(Nu��s)�����sN���sN�sNN���s(�����s)}���sVlist
����r�Zbad_stack_errorsrrrr�test_bad_stack�s^�.z$AbstractUnpickleTests.test_bad_stackcCs\ddddddddd	d
ddd
dddddddddddddddddg}|D]}|�|j|�qDdS)NsN(.sN(2scbuiltins
list
)(Rscbuiltins
list
()Rs]N(ascbuiltins
ValueError
)R}(bscbuiltins
ValueError
)R(}bs(NdsN(p1
sN(qsN(rs}NN(ss}N(Nss}(NNss}((uscbuiltins
list
)(�scbuiltins
list
()�sN(�sNN(�sN(N�sNNN(�sNN(N�sN(NN�s]((�scbuiltins
list
)}(�scbuiltins
list
)(}�scbuiltins
list
()}�sVbuiltins
(Vlist
�sVbuiltins
Vlist
(�sN(�rHrrrr�
test_bad_mark�sB�#z#AbstractUnpickleTests.test_bad_markcUCs�|�td�|�td�ddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWgU}|D]}|�|j|�q�dS)XN��N�BsBsBsBab�CsCsCab�FsF0.0sF0.00�GsGr�sI0�JsJ�K�LsL0sL10sL0LsL10L�MsM�SsS'abc'�TsTsTsTab�UsUsUab�VsVabcr�sXsXsXabs(cs
(cbuiltinss(cbuiltins
s(cbuiltins
listsNgsNg0s(is
(ibuiltinss(ibuiltins
s(ibuiltins
listsNhsNjsNjsNpsNp0sNqsNrsNr������s���s�����s���s�s�ab��s�s	�s�ab��s�s	�s�ab��s�s	�s�ab��s�s	�s
�N)r��EOFErrorZtruncated_errorsrrrr�test_truncated_datas��Yz)AbstractUnpickleTests.test_truncated_datac		s^td�}td�}t�t�|�tjt�tj�	dt�|�tjj
t�ttj�td�d��}|�
|�d��W5QRXttj�td�d��}|�
|�d��W5QRX|�td�|�td	�ddl}d
�g�t�d�����fdd
�}tj|d�}tj|d�}|��|�����|j��|��|��ddlm}|�dd��D�|gd�dS)NzI
        import threading
        barrier = threading.Barrier(2)
        zs
        import locker
        locker.barrier.wait()
        class ToBeUnpickled(object):
            pass
        rz	locker.py�wb�utf-8zlocking_import.py�locker�locking_imports'�clocking_import
ToBeUnpickled
q)�q.r cs�����t����dSr)�waitr�rr�r��barrierZpickle_bytes�resultsrr�t�sz:AbstractUnpickleTests.test_unpickle_module_race.<locals>.t)�target)�
ToBeUnpickledcSsg|]}t|��qSr)r_��.0r!rrr�
<listcomp>�szCAbstractUnpickleTests.test_unpickle_module_race.<locals>.<listcomp>r�)r�os�mkdirrZ
addCleanup�shutil�rmtree�sys�path�insert�remove�open�joinr8r�r
rh�	threading�Barrier�Threadr�rjrlrirpr�)	r&Z
locker_moduleZlocking_import_module�frhrn�t1�t2rprrkr�test_unpickle_module_race`s>
�

�z/AbstractUnpickleTests.test_unpickle_module_race)N)4r0r1r2r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��requires_32br�r�rrrrrrr	r
rrrrrrrrrrr)r+r/r0rIrJrerr�rrrrr�;sj
9






2'_r�c@seZdZdZejZdd�ZejZdd�Zdd�Z	dd	�Z
ed
fdd�Zd
d�Z
dd�Zdd�Zed
fdd�Zdd�Zdd�Zdd�Zed
fdd�Zdd�Zdd �Zd!d"�Zed
fd#d$�Zd%d&�Zd'd(�Zd)d*�Zed
fd+d,�Zd-d.�Zd/d0�Zd1d2�Zed
fd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%d?d@�Z&dAdB�Z'dCdD�Z(dEdF�Z)dGdH�Z*dIdJ�Z+dKdL�Z,dMdN�Z-dOdP�Z.dQdR�Z/dSdT�Z0dUdV�Z1dWdX�Z2dYdZ�Z3d[d\�Z4d]d^�Z5d_d`�Z6dadb�Z7dcdd�Z8dedf�Z9dgdh�Z:e;didjdk�dldm��Z<dndo�Z=dpdq�Z>drds�Z?dtdu�Z@dvdw�ZAdxdy�ZBdzd{�ZCd|d}�ZDd~d�ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^e_d�d���Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�dÄZhd�dńZid�Zjd�Zkd�dɄZlemjnd�d˄�Zod�d̈́Zpd�dτZqemjnd�dф�Zrd�dӄZsd�dՄZtd�dׄZud�dلZvd�dۄZwd�d݄Zxd�d߄Zyd�d�Zzd�d�Z{d�d�Z|d�d�Z}d�d�Z~d�d�Zd�d�Z�e���e�d�kd�d�d��Z�d�S)��AbstractPickleTestsFcCsdSrrr)rrr�setUp�szAbstractPickleTests.setUpcCs�tD]�}td�}|�||�}|�|�}|�||�d}|�||�}|�|�}|�||�td|�}|�||�}|�|�}|�||�qdS)Nr!)rrr)�	protocolsrU�dumpsr�r�rX�r&�protor!�sr�rrr�	test_misc�s



zAbstractPickleTests.test_misccCs6|j}tD]&}|�||�}|�|�}|�||�q
dSr)r�r�r�r�r�)r&rr�r�r�rrr�test_roundtrip_equality�s

z+AbstractPickleTests.test_roundtrip_equalitycCsjddlm}ddlm}dtfdtffD]<\}}|�|j|�}|�}|||d�|��}|�	||�q(dS)Nr)�StringIO��disr)�out)
r,r�rr��	DATA0_DIS�	DATA1_DISr�r�r5r�)r&r�r�r�rr�Zfileliker�rrr�dont_test_disassembly�sz)AbstractPickleTests.dont_test_disassemblyrc	Cst|�}|�|�t|tjd�D]N}|�||�}|�|�}|�||�||�}|�t|�d�|�	|d|�q dS�Nrr)
r�r�r�HIGHEST_PROTOCOLr�r��assertIsInstancer��lenr�)	r&ry�aslist�minprotocol�lr�r�r!r�rrr�_test_recursive_list�s

z(AbstractPickleTests._test_recursive_listcCs|�t�dSr)r�r�r)rrr�test_recursive_list�sz'AbstractPickleTests.test_recursive_listcCs|jtdd�dS�Nr�)r�)r��MyListr)rrr�test_recursive_list_subclass�sz0AbstractPickleTests.test_recursive_list_subclasscCs|jtdd�d�dS)NcSs|jSr�r�r rrr�<lambda>�rKz>AbstractPickleTests.test_recursive_list_like.<locals>.<lambda>�r�)r��REX_sixr)rrr�test_recursive_list_like�sz,AbstractPickleTests.test_recursive_list_likec	Cs,|�f}|d�|�t|tjd�D]r}|�||�}|�|�}|�|t�|�t	|�d�|�|d|�||d�}|�t	|�d�|�
|d|�q&|\}t|tjd�D]v}|�||�}|�|�}|�||�||�}|�t	|�d�|�|dt�|�t	|d�d�|�
|dd|�q�dSr<)r�r�rr�r�r�r��tupler�r�r�)	r&ryr�r�rnr�r�r!r�rrr�_test_recursive_tuple_and_list�s*

z2AbstractPickleTests._test_recursive_tuple_and_listcCs|�t�dSr)r�r�r)rrr�test_recursive_tuple_and_listsz1AbstractPickleTests.test_recursive_tuple_and_listcCs|jtdd�dSr�)r�r�r)rrr�&test_recursive_tuple_and_list_subclasssz:AbstractPickleTests.test_recursive_tuple_and_list_subclasscCs|jtdd�d�dS)NcSs|jSrr�r rrrr�rKzHAbstractPickleTests.test_recursive_tuple_and_list_like.<locals>.<lambda>r�)r�r�r)rrr�"test_recursive_tuple_and_list_likesz6AbstractPickleTests.test_recursive_tuple_and_list_likec	Csx|�}||d<t|tjd�D]T}|�||�}|�|�}|�||�||�}|�t|���dg�|�	|d|�qdS�Nr)
r�rr�r�r�r�r�r�r�r��	r&ry�asdictr��dr�r�r!r�rrr�_test_recursive_dicts
z(AbstractPickleTests._test_recursive_dictcCs|�t�dSr)r�rbr)rrr�test_recursive_dictsz'AbstractPickleTests.test_recursive_dictcCs|jtdd�dSr�)r��MyDictr)rrr�test_recursive_dict_subclasssz0AbstractPickleTests.test_recursive_dict_subclasscCs|jtdd�d�dS)NcSs|jSr��tabler rrrr�!rKz>AbstractPickleTests.test_recursive_dict_like.<locals>.<lambda>�r�)r��	REX_sevenr)rrr�test_recursive_dict_like sz,AbstractPickleTests.test_recursive_dict_likec	Cs.|�f}||dd<t|tjd�D]t}|�||�}|�|�}|�|t�|�t|�d�|�|d|�||d�}|�t	|�dg�|�
|d|�q$|\}t|tjd�D]x}|�||�}|�|�}|�||�||�}|�t	|�dg�|�|dt�|�t|d�d�|�
|dd|�q�dSr<)r�rr�r�r�r�r�r�r�r�r��	r&ryr�r�rnr�r�r!r�rrr�_test_recursive_tuple_and_dict#s*

z2AbstractPickleTests._test_recursive_tuple_and_dictcCs|�t�dSr)r�rbr)rrr�test_recursive_tuple_and_dict=sz1AbstractPickleTests.test_recursive_tuple_and_dictcCs|jtdd�dSr�)r�r�r)rrr�&test_recursive_tuple_and_dict_subclass@sz:AbstractPickleTests.test_recursive_tuple_and_dict_subclasscCs|jtdd�d�dS)NcSs|jSrr�r rrrr�DrKzHAbstractPickleTests.test_recursive_tuple_and_dict_like.<locals>.<lambda>r�)r�r�r)rrr�"test_recursive_tuple_and_dict_likeCsz6AbstractPickleTests.test_recursive_tuple_and_dict_likec	Cs�|�}d|t|�<t|tjd�D]t}|�||�}|�|�}|�||�||�}|�t|�	��d�|�t
|�	��dt�|�t
|�	��dj|�q"dSr�)
rQr�rr�r�r�r�r�r�r�r�r�rRr�rrr�_test_recursive_dict_keyFs
z,AbstractPickleTests._test_recursive_dict_keycCs|�t�dSr)r�rbr)rrr�test_recursive_dict_keyTsz+AbstractPickleTests.test_recursive_dict_keycCs|jtdd�dSr�)r�r�r)rrr� test_recursive_dict_subclass_keyWsz4AbstractPickleTests.test_recursive_dict_subclass_keycCs|jtdd�d�dS)NcSs|jSrr�r rrrr�[rKzBAbstractPickleTests.test_recursive_dict_like_key.<locals>.<lambda>r�)r�r�r)rrr�test_recursive_dict_like_keyZsz0AbstractPickleTests.test_recursive_dict_like_keyc	CsN|�f}d|dt|�<t|tjd�D]�}|�||�}|�|�}|�|t�|�t	|�d�|�|d|�||d�}|�t	|�d�|�t
|���dt�|�t
|���dj
|�q(|\}t|tjd�D]t}|�||�}|�|�}|�||�||�}|�t	|�d�|�t
|���dt�|�t
|���dj
d|�q�dSr�)rQr�rr�r�r�r�r�r�r�r�r�r�rRr�rrr�"_test_recursive_tuple_and_dict_key]s*

z6AbstractPickleTests._test_recursive_tuple_and_dict_keycCs|�t�dSr)r�rbr)rrr�!test_recursive_tuple_and_dict_keyysz5AbstractPickleTests.test_recursive_tuple_and_dict_keycCs|jtdd�dSr�)r�r�r)rrr�*test_recursive_tuple_and_dict_subclass_key|sz>AbstractPickleTests.test_recursive_tuple_and_dict_subclass_keycCs|jtdd�d�dS)NcSs|jSrr�r rrrr��rKzLAbstractPickleTests.test_recursive_tuple_and_dict_like_key.<locals>.<lambda>r�)r�r�r)rrr�&test_recursive_tuple_and_dict_like_keysz:AbstractPickleTests.test_recursive_tuple_and_dict_like_keycCs�t�}|�t|��tdtjd�D]`}|�||�}|�|�}|�|t�|�	t
|�d�|�t|�dt�|�t|�dj
|�q$|\}tdtjd�D]\}|�||�}|�|�}|�|t�|�|j
t�|�	t
|j
�d�|�t|j
�d|�q�dS)Nr!rr)r��addrQr�rr�r�r�r�r�r�r�r�rR�r&r�r�r�r!rrr�test_recursive_set�s"

z&AbstractPickleTests.test_recursive_setcCs^t�}||_tD]H}|�||�}|�|�}|�|t�|�t|�t|��|�|j|�qdSr)	rO�attrr�r�r�r�r��dirr�)r&�ir�r�r!rrr�test_recursive_inst�s
z'AbstractPickleTests.test_recursive_instcCs�g}d|i}t�}||_|�|�tD]�}|�||�}|�|�}|�|t�|�t	|�d�|�t
|d�t
|��|�t|dj���dg�|�|djd|�q&dSr�)
rOr�r�r�r�r�r�r�r�r�r�r�r�)r&r�r�r�r�r�r!rrr�test_recursive_multi�s

z(AbstractPickleTests.test_recursive_multicCs�t�}||g�|_t|j�}tD]f}|�||�}|�|�}|�|j|�|�t|j�d�|�t	|j�dt�|�
t	|j�d|�q |j}tD]`}|�||�}|�|�}|�||�|�t|�d�|�t	|�dt�|�
t	|�dj|�q�dSr�)rOr�r_r�r�r�r�r�r�r�r�)r&�factory�ornr�r�r!rrr�#_test_recursive_collection_and_inst�s$


z7AbstractPickleTests._test_recursive_collection_and_instcCs|�t�dSr)r�r�r)rrr�test_recursive_list_and_inst�sz0AbstractPickleTests.test_recursive_list_and_instcCs|�t�dSr)r�r�r)rrr�test_recursive_tuple_and_inst�sz1AbstractPickleTests.test_recursive_tuple_and_instcCs|�tj�dSr)r�rb�fromkeysr)rrr�test_recursive_dict_and_inst�sz0AbstractPickleTests.test_recursive_dict_and_instcCs|�t�dSr)r�r�r)rrr�test_recursive_set_and_inst�sz/AbstractPickleTests.test_recursive_set_and_instcCs|�t�dSr)r��	frozensetr)rrr�!test_recursive_frozenset_and_inst�sz5AbstractPickleTests.test_recursive_frozenset_and_instcCs|�t�dSr)r�r�r)rrr�%test_recursive_list_subclass_and_inst�sz9AbstractPickleTests.test_recursive_list_subclass_and_instcCs|�t�dSr)r��MyTupler)rrr�&test_recursive_tuple_subclass_and_inst�sz:AbstractPickleTests.test_recursive_tuple_subclass_and_instcCs|�tj�dSr)r�r�r�r)rrr�%test_recursive_dict_subclass_and_inst�sz9AbstractPickleTests.test_recursive_dict_subclass_and_instcCs|�t�dSr)r��MySetr)rrr�$test_recursive_set_subclass_and_inst�sz8AbstractPickleTests.test_recursive_set_subclass_and_instcCs|�t�dSr)r��MyFrozenSetr)rrr�*test_recursive_frozenset_subclass_and_inst�sz>AbstractPickleTests.test_recursive_frozenset_subclass_and_instcCsJt�}||_tD]4}|�||�}|�|�}|�|t�|�|j|�qdSr)�	REX_state�stater�r�r�r�r�r�rrr�test_recursive_inst_state�s
z-AbstractPickleTests.test_recursive_inst_statecCs�t�f}||d_tD]X}|�||�}|�|�}|�|t�|�t|�d�|�|dt�|�	|dj|�q|\}tD]X}|�||�}|�|�}|�|t�|�|jt�|�t|j�d�|�	|jd|�qzdSr<)
r�r�r�r�r�r�r�r�r�r�)r&rnr�r�r!rrr�#test_recursive_tuple_and_inst_state�s"


z7AbstractPickleTests.test_recursive_tuple_and_inst_statecCsLdddddddg}tD]0}|D]&}|�||�}|�|�}|�||�qqdS)Nr�z<\u>u<\ሴ>z<
>z<\>u<\𒍅>u<�>�r�r�r�r�)r&Zendcasesr��ur�u2rrr�test_unicode	s�
z AbstractPickleTests.test_unicodecCs4d}tD]&}|�||�}|�|�}|�||�qdS)Nu𒍅r�)r&rnr�rr�rrr�test_unicode_high_planes

z+AbstractPickleTests.test_unicode_high_planecCs�tD]�}dD]"}|�||�}|�||�|��qdd�td�D�D]"}|�||�}|�||�|��qBdd�td�D�D]"}|�||�}|�||�|��qxqdS)N�rK�xyzs,xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzcSsg|]}t|g��qSr�rl�rrr�rrrrs sz2AbstractPickleTests.test_bytes.<locals>.<listcomp>�cSsg|]}t||g��qSrr�r�rrrrs#s)r�r�r�r�r�)r&r�r�rrrr�
test_bytesszAbstractPickleTests.test_bytescCs�tD]�}dD]�}t|�}|�||�}|�|�}|�||�|�||�|dkrn|�d|�|�tt	j
|��q|dkr�|�d|�|�tt	j|��q|dkr|�d|�|�tt	j
|��qqdS)Nr�r s	bytearrayr!rh)r�rr�r�r�r��assertIn�
assertTruerr�GLOBAL�STACK_GLOBAL�assertNotIn�
BYTEARRAY8)r&r�r�r[rZbbrrr�test_bytearray's 
z"AbstractPickleTests.test_bytearraycCsTtD]J}tj}|r||fD]&}|�||�}|�|�}|�||�q|d?}qqdSr�)r�rx�maxsizer�r�r�)r&r�rrr�Zn2rrr�	test_ints:s
zAbstractPickleTests.test_intsc	Cs�tD]`}dD]V}d|>}|d||dfD]6}||fD]&}|�||�}|�|�}|�||�q8q*qqtdd�}||d>7}||fD]6}|�|d�}|�|�}|�t|�t�|�||�q�dS)N)r�i�i��irZdeadbeeffeedface�i@Br�)r�r�r�r��intr�r_r�)	r&r�ZnbitsZnbaseZnposrrr�rrrr�	test_longDs


zAbstractPickleTests.test_longcCsfddddddddd	d
dg}|dd
�|D�}tD]0}|D]&}|�||�}|�|�}|�||�q8q0dS)Nggg+�p�hg�Z��*)g_D��9g�������?g�?g��Q�	@g�m�"wp@g�W�T��Dgꌠ9Y>)FcSsg|]
}|�qSrrrqrrrrs^sz2AbstractPickleTests.test_float.<locals>.<listcomp>r�)r&Ztest_valuesr�rRrr�rrr�
test_float[s�
zAbstractPickleTests.test_float�LC_ALL�de_DE�fr_FRcCs |�|�dd�dd�d�dS)Ng333333�?rr sF1.)r�r�r)rrr�test_float_formatesz%AbstractPickleTests.test_float_formatcCs6tD],}t�}|�||�}|�|�}|�|t�qdSr)r��AAAr�r�r��REDUCE_A�r&r��instr�r�rrr�test_reducejs

zAbstractPickleTests.test_reducecCs:tD]0}tdd�}|�||�}|�|�}|�||�qdS)Nrr�)r�rXr�r�r�rrrr�test_getinitargsqs


z$AbstractPickleTests.test_getinitargscCs:t�}tD]*}|�||�}|�|�}|�|j|j�q
dSr)r]r�r�r�r�rs�r&rZr�r�r[rrr�test_metaclassxs

z"AbstractPickleTests.test_metaclasscCs^tdtf�}t�ttj�tD]:}|�||�}|�|�}|�	||�|�
t|�t|��qdS)NZmy_dynamic_class)rar�r=rr^rSr�r�r�r�r�r_rrrr�test_dynamic_classs
z&AbstractPickleTests.test_dynamic_classcCs�ddl}ddl}|��}tD]�}|�||�}|�|�}|�||�|�|j�}|�||�}|�|�}|�||�t	|d�r|�
|j�}|�||�}|�|�}|�||�qdS)Nr�statvfs)�timert�	localtimer�r�r�r��stat�curdirr�r)r&rrtrnr�r�r�rrr�test_structseq�s 



z"AbstractPickleTests.test_structseqcCs0tD]&}|�d|�}|�|�}|�d|�qdS�N.)r�r�r�r��r&r�r�r�rrr�
test_ellipsis�s
z!AbstractPickleTests.test_ellipsiscCs0tD]&}|�t|�}|�|�}|�t|�qdSr)r�r�r�r�r�rrrr�test_notimplemented�s
z'AbstractPickleTests.test_notimplementedcCsLddtg}|D]8}tD].}|�t|�|�}|�|�}|�t|�|�qqdSr)r�r�r�r_r�r�)r&Z
singletonsZ	singletonr�r�r�rrr�test_singleton_types�s

z(AbstractPickleTests.test_singleton_typesc
Cs�tD]N}|�d|�}|dkr>tjt|g�}|�|�|��q|�ttj|�d�qtdd}tj	tj
}tjt|g�|}z|�|�Wn2tk
r�}z|�
dt|��W5d}~XYnX|�d�dS)Nr�rr�rzunsupported pickle protocolz0expected bad protocol number to raise ValueError)r�r�r�PROTOrlr��
startswithr�r�NONEr�r�r�r�rWZfail)r&r�r
Zproto_headerZoobZ
build_noneZ	badpickle�errrrr�
test_proto�s"zAbstractPickleTests.test_protocCsLd}tD]>}|�||�}|�|�}|�||�|�ttj|�|dk�qdS)N��UJ^w,3�|	r�)r�r�r�r�r�rr�LONG1�r&r!r�r�r�rrr�
test_long1�s
zAbstractPickleTests.test_long1cCsPdd>}tD]>}|�||�}|�|�}|�||�|�ttj|�|dk�qdS)Nrr�r�)r�r�r�r�r�rr�LONG4rrrr�
test_long4�s
zAbstractPickleTests.test_long4cCs�tjtjtjtjtjtjtjtjtjtjtjtjtjtjtjtjtjtjtjtjd�}d}d}d}d}d}tD]`}|||||fD]L}|�||�}	|�|	�}
|�	||
�|t
|d�t|�f}|�t
||	��q�qndS)N))rr)rr)rr�)rr )rr!)rr)rr�rr�)rr �rr!)r�r�r�r)r�r�)r�r )r�r!)r r)r r)r r�)r r �r r!r)rr!�rr�r )rr�r r!r )r�TUPLE�EMPTY_TUPLE�TUPLE1�TUPLE2�TUPLE3r�r�r�r��minr�r�r)r&�expected_opcoderZr[r�r��er�r!r�r�rrrr�test_short_tuples�sB�
z%AbstractPickleTests.test_short_tuplesc
Cs�tjtjtjtjtjtjtjtjtjtjtjtjd�}tD]^}dD]T}|�||�}|�|�}|�||k||||f�|t	|d�|f}|�t
||��qBq:dS)N))rN)rN)r�N)r N)rT)rT)r�T)r T)rF)rF)r�F)r F)NFTr )rr�INT�NEWTRUE�NEWFALSEr�r�r�r�r+r)r&r,r�r!r�r�rrrr�test_singletons�s(�
z#AbstractPickleTests.test_singletonscCsJtdddg�}d|_d|_tD]&}|�||�}|�|�}|�||�qdS�Nrr�r r�hello)r�r�r�r�r�r�r�rrrr�test_newobj_tuples
z%AbstractPickleTests.test_newobj_tuplecCsJtdddg�}d|_d|_tD]&}|�||�}|�|�}|�||�qdSr3)r�r�r�r�r�r�r�rrrr�test_newobj_lists
z$AbstractPickleTests.test_newobj_listc	Cs�tD]�}tD]x}|j}||j�}d|_|�||�}|�|�}|||||t|�f}|�||�|�	||�||�|�|�	|j
|j
|�qqdS�Nr)r��	myclasses�__base__�sampler�r�r�r_r�r�rE)r&r�rD�Br!r�r��detailrrr�test_newobj_generic's

z'AbstractPickleTests.test_newobj_genericc	Cs�tdd�}ttfD]}|�|�qtD]�}|D]�}|j}||j�}d|_t�	|�}|�
||�}|�|�}	|�t
|	�t
|��|||||	t
|	�f}
|�||�||	�|
�|�|j|	j|
�q0q(dSr7)r8�MyIntr�r{r�r9r:r��weakref�proxyr�r�r�r_rE)r&�classesr�r�rDr;r!rr�r�r<rrr�test_newobj_proxies4s


z'AbstractPickleTests.test_newobj_proxiescCsDt}t�t�}|�|d�}zda|�ttjf|j|�W5|aXdS)Nr!r)�SimpleNewObjr�r�r�r*rr�r�)r&�saver�r[rrr�test_newobj_not_classGs
z)AbstractPickleTests.test_newobj_not_classcCs�t|�}z�t�td|�tdddg�}d|_d|_|�|d�}|�	t�
d�|�|�	d|�|�t||��|�
|�}|�||�|�|d�}|�t�
d�|�|�d|�|�t||�d	t|��|�
|�}|�||�W5|��XdS)
Nr�rr�r rr4rgsMyListT)r;rCr=rBr0r�r�r�r�r�r��assertFalserr�r�r�r��repr)r&Zextcode�opcoder-r!�s1r��s2rrr�produce_global_extWs&

z&AbstractPickleTests.produce_global_extcCs |�dtj�|�dtj�dS)Nrr�)rKr�EXT1r)rrr�test_global_ext1ssz$AbstractPickleTests.test_global_ext1cCs.|�dtj�|�dtj�|�dtj�dS)Nr�r�iͫ)rKr�EXT2r)rrr�test_global_ext2wsz$AbstractPickleTests.test_global_ext2cCs.|�dtj�|�dtj�|�dtj�dS)N�r�i�ͫ)rKr�EXT4r)rrr�test_global_ext4|sz$AbstractPickleTests.test_global_ext4cCs�d}tt|��}tD]B}|�||�}|�|�}|�||�ttj|�}|�	||dk�qd}tt|��}tD]V}|�||�}|�|�}|�||�ttj|�}|dkr�|�	|d�ql|�
|dk�qldS�N�
r��	r�)r�r�r�r�r�r�rr�APPENDSr�r�)r&rr!r�r�r�Znum_appendsrrr�test_list_chunking�s$

z&AbstractPickleTests.test_list_chunkingcCs�d}t�t|��}tD]N}|�||�}|�|t�|�|�}|�||�t	t
j|�}|�||dk�qd}t�t|��}tD]V}|�||�}|�|�}|�||�t	t
j|�}|dkr�|�|d�q||�
|dk�q|dSrS)rbr�r�r�r�r�rr�r�rr�SETITEMSr�r�)r&rr!r�r�r�Znum_setitemsrrr�test_dict_chunking�s&

z&AbstractPickleTests.test_dict_chunkingcCs�d}tt|��}tD]T}|�||�}|�|�}|�||�ttj|�}|dkr\|�	|d�q|�	|d�qd}tt|��}tD]T}|�||�}|�|�}|�||�ttj|�}|dkr�|�	|d�q~|�
|d�q~dS)NrTr!rrrUr�)r�r�r�r�r�r�rr�ADDITEMSr��assertGreaterEqual)r&rr!r�r�r�Znum_additemsrrr�test_set_chunking�s(

z%AbstractPickleTests.test_set_chunkingc
Cs�t�td�}d|_tD]�}|j|d��t|�||�}|dkrJ|�d|�n|�d|�|�tt	j
|�d|k�|�tt	j|��|�
|�}|�||�W5QRXqdS)N����r�r�
I64206�M�r�)rCr�r�r�r�r�r�r�rr�NEWOBJrF�	NEWOBJ_EXr�r�rrrr�test_simple_newobj�s�
z&AbstractPickleTests.test_simple_newobjc
Cs�t�td�}d|_tD]�}|j|d���|�||�}|dkrJ|�d|�n8|dkr`|�d|�n"|dkrv|�d	|�n|�d
|�|�tt	j
|�d|k�|�tt	j|��|�
|�}|�||�W5QRXqdS�Nr]r^r_rr`r�rar!s	XFACEs�FACE)�
ComplexNewObjr�r�r�r�r�r�r�rrrbrFrcr�r�rrrr�test_complex_newobj�s$�
z'AbstractPickleTests.test_complex_newobjc
Cs�t�td�}d|_tD]�}|j|d���|�||�}|dkrJ|�d|�n8|dkr`|�d|�n"|dkrv|�d	|�n|�d
|�|�tt	j
|��|�tt	j|�d|k�|�
|�}|�||�W5QRXqdSre)�ComplexNewObjExr�r�r�r�r�r�rFrrrbr�rcr�r�rrrr�test_complex_newobj_ex�s$�
z*AbstractPickleTests.test_complex_newobj_excCs@tdddg�}d|_d|_|�|d�}|�|�}|�||�dSr3)�SlotListr�r�r�r�r�)r&r!r�r�rrr�test_newobj_list_slots�s
z*AbstractPickleTests.test_newobj_list_slotscCsTtD]J}t�}|�|jd�|�||�}|�|jd�|�|�}|�|jd�qdSr<)r��REX_oner��_reduce_calledr�r�r�rrr�'test_reduce_overrides_default_reduce_ex	s
z;AbstractPickleTests.test_reduce_overrides_default_reduce_excCsTtD]J}t�}|�|jd�|�||�}|�|j|�|�|�}|�|jd�qdSr)r��REX_twor��_protor�r�r�rrr�test_reduce_ex_called	s
z)AbstractPickleTests.test_reduce_ex_calledcCsTtD]J}t�}|�|jd�|�||�}|�|j|�|�|�}|�|jd�qdSr)r��	REX_threer�rpr�r�r�rrr�test_reduce_ex_overrides_reduce	s
z3AbstractPickleTests.test_reduce_ex_overrides_reducecCsTtD]J}t�}|�|jd�|�||�}|�|j|�|�|�}|�|j|�qdSr)r��REX_fourr�rpr�r�r�rrr�test_reduce_ex_calls_base"	s
z-AbstractPickleTests.test_reduce_ex_calls_basecCsTtD]J}t�}|�|jd�|�||�}|�|jd�|�|�}|�|jd�qdSr<)r��REX_fiver�rmr�r�r�rrr�test_reduce_calls_base+	s
z*AbstractPickleTests.test_reduce_calls_basecCs&t�}tD]}|�t|j||�q
dSr)�
BadGetattrr�r��RuntimeErrorr�)r&r!r�rrr�test_bad_getattr4	sz$AbstractPickleTests.test_bad_getattrc	Cs�Gdd�dt�}Gdd�dt�}tD]X}z|�|�|�Wntjk
rPYnXz|�|�|�Wq$tjk
rzYq$Xq$dS)Nc@seZdZdd�ZdS)z7AbstractPickleTests.test_reduce_bad_iterator.<locals>.CcSstddgdfSrM)r�r)rrrrS?	szBAbstractPickleTests.test_reduce_bad_iterator.<locals>.C.__reduce__N�r0r1r2rSrrrrrD>	srDc@seZdZdd�ZdS)z7AbstractPickleTests.test_reduce_bad_iterator.<locals>.DcSstdddgfSrM)rbr)rrrrSC	szBAbstractPickleTests.test_reduce_bad_iterator.<locals>.D.__reduce__Nr{rrrrrIB	srI)r�r�r�r�
PicklingError)r&rDrIr�rrr�test_reduce_bad_iterator;	sz,AbstractPickleTests.test_reduce_bad_iteratorc
Cs�dd�td�D�}tdd�|D��}t|�t|�t|�g}tD]>}|j|d��(|�||�}|�|�}|�||�W5QRXq>dS)Ncss|]}dt|�VqdS)ZaaaNrVr�rrr�	<genexpr>U	sz>AbstractPickleTests.test_many_puts_and_gets.<locals>.<genexpr>rcss|]}|dddgfVqdS)r!rhr"Nr)rr�krrrr~V	sr_)r�rbr�r�r�r�r�)r&r�Z
large_dictrwr�r�r�rrr�test_many_puts_and_getsR	s
z+AbstractPickleTests.test_many_puts_and_getsc	CsjtD]`}t�}d|_d|_|�||�}|�|�}t|j�}t|j�}t||�D]\}}|�	||�qNqdS)Nrr4)
r�rDr�r�r�r��sortedrE�zipr�)	r&r�r!r�r�Zx_keysZy_keysZx_keyZy_keyrrr�test_attribute_name_interning_	s


z1AbstractPickleTests.test_attribute_name_interningcCs>|�td�d�}|�|t�|�tdg�d�}|�|t�dS)Nrhr�r )r�r�r�r�r��	DATA_SET2r�rrr�test_pickle_to_2xm	sz%AbstractPickleTests.test_pickle_to_2xcCsTtD]J}dtddtf}|�||�}|�|�}|�t|�t|��|�||�qdS)Nrsxyix)r�r+r�r�r�r�)r&r�r�r�r�rrr�test_large_picklesw	s
z&AbstractPickleTests.test_large_picklesc
s�tD]v��j�d��`��fdd�td�D�}ttt|��}��t|�|��dkrp|D]}��t	t
j|��qXW5QRXqdS)Nr_csg|]}��d|���qS�r��r�)rrr�r�r&rrrs�	szDAbstractPickleTests.test_int_pickling_efficiency.<locals>.<listcomp>�Fr�)r�r�r�r��mapr�r�r�rFrr�LONG)r&ZpicklesZsizesrrr�r�test_int_pickling_efficiency�	sz0AbstractPickleTests.test_int_pickling_efficiencycCs6|�||�}|�t||��|�|�}|�||�dSr)r�r�rr�r�)r&rwrHr�r
rrrr�_check_pickling_with_opcode�	s
z/AbstractPickleTests._check_pickling_with_opcodecCsFtdddg�}tD].}|dkr0|�|tj|�q|�|tj|�qdS)Nrr�r r)r�r�r�r�APPENDrV�r&rwr�rrr�test_appends_on_non_lists�	s
z-AbstractPickleTests.test_appends_on_non_listscCsHtdddd��}tD].}|dkr2|�|tj|�q|�|tj|�qdS)Nr�������r%r)r�r�r�r�SETITEMrXr�rrr�test_setitems_on_non_dicts�	s
z.AbstractPickleTests.test_setitems_on_non_dictsr!rPcCs<d}}dddddh}t�|�D]�\}}}|dk	rJ|�||�||krJd}|dk	r~|�|jd�|j|kr�|�t|�|j�nX|jdks�|j|kr�t|�|jkr�|dk	r�|�|||j�d}n|dkr�|jdkr�|}|jdkr |�	||j�|d	|}q t|�}|dk	�r|�
||�n|dk	�r8|�|||j�dS)
a
        Check the arguments of FRAME opcodes in a protocol 4+ pickle.

        Note that binary objects that are larger than FRAME_SIZE_TARGET are not
        framed by default and are therefore considered a frame by themselves in
        the following consistency check.
        N�BINBYTES�
BINUNICODE�	BINBYTES8�BINUNICODE8r��FRAMEr�	)rr�assertLessEqual�assertNotEqualrcr��FRAME_SIZE_TARGET�
assertLess�FRAME_SIZE_MINr[r�)r&r
Z	frame_endZframeless_startZframeless_opcodesrrJ�posrrr�check_frame_opcodes�	sD�

��
�


z'AbstractPickleTests.check_frame_opcodesc
Cs�ttd��}tdtjd�D]�}|j|d��j|�||�}|�|�}|�||�t|�t	tj
|�}|�||jd�|�
||jd�|�|�W5QRXqdS)Ni��r!rr_r�)r�r�rr�r�r�r�r�r�rr��
assertGreaterr�r�r�)r&rwr�r
rZbytes_per_framerrr�test_framing_many_objects�	s 

���z-AbstractPickleTests.test_framing_many_objectscCsd}dd�td�D�}d|f|d|d|f�}tdtjd	�D]�}d
D]�}|j||d���|sp|�||�}nDt|d�s�W5QR�qJt��}|j||d
�}||_	|�
|�|��}|�|�}	|�
dd�|D�dd�|	D��|�
||	�ttj|�}
|�
|
d	�|�|�W5QRXqJqBdS)NicSsg|]
}|g�qSrrr�rrrrs�	szBAbstractPickleTests.test_framing_large_objects.<locals>.<listcomp>rT�x�y�zr!r)FT)r��fast�pickler�rncSsg|]}t|��qSr�r�rqrrrrs�	scSsg|]}t|��qSrr�rqrrrrs�	s)r�rr�r�r�r�r,r4r�r��dumpr5r�r�rr�r�)r&�NZsmall_itemsrwr�r�r
�bufr�r�n_framesrrr�test_framing_large_objects�	s.


�z.AbstractPickleTests.test_framing_large_objectscs�tjdkrdSddd�}|j�d}ttfD]����fdd�t|�D�}tdtjd�D]z}|�||�}||�}|�ttj	|�d�|�||�
|��||d	d
��}|�ttj	|�ttj	|��|�||�
|��qVq*dS)Nr!c
Ss�g}d}t�|�D]\}}}|jdkr|�|�qt�}d}t|�D].\}	}|rZ||	�rZqD||||�7}||}qD|||d�7}|S)z+Remove frame opcodes from the given pickle.r�r�rN)rrrcr�r�	enumerate)
r
Z
keep_frameZframe_startsZframe_opcode_sizerH�_r�Z	newpickleZlast_frame_endr�rrr�
remove_frames
s

z?AbstractPickleTests.test_optional_frames.<locals>.remove_frames�csi|]}|�|g���qSrrr��Z
bytes_type�
frame_sizerr�
<dictcomp>$
sz<AbstractPickleTests.test_optional_frames.<locals>.<dictcomp>rrcSs|dS)Nr�r)r�rrrr�-
rKz:AbstractPickleTests.test_optional_frames.<locals>.<lambda>)N)rr�r�rlrr�r�r�rr�r�r�)r&r�Z
num_framesrwr�r
Zframeless_pickleZsome_frames_picklerr�r�test_optional_frames
s"


�z(AbstractPickleTests.test_optional_framesc
s�Gdd�d�}tdtjd�D�]Z}dd�ttd��D�}|�d�jd	d�|�}��||��|�|��}��	|�}��
||���t|j
�d�~t����
|��|�t|�d�jd}��t|j
�|���t|j
�d
|d�dd�|j
D�}�fd
d�|D�}	�fdd�|D�}
dd�|D�}|	D]}��|d
�j|��q<��t|�t|	�t|
�d|�qdS)Nc@s(eZdZdZdd�Zdd�Zdd�ZdS)	zYAbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.ChunkAccumulatorz2Accumulate pickler output in a list of raw chunks.cSs
g|_dSr)�chunksr)rrrr96
szbAbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.ChunkAccumulator.__init__cSs|j�|�dSr)r�r�)r&�chunkrrrr88
sz_AbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.ChunkAccumulator.writecSsd�|j�S)NrK)r}r�r)rrr�concatenate_chunks:
szlAbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.ChunkAccumulator.concatenate_chunksN)r0r1r2r:r9r8r�rrrr�ChunkAccumulator4
sr�r!rcSs,g|]$}t|��d�|ddt|�if�qS)r�rr�)rWr�r�rrrrs>
s�zSAbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.<listcomp>g��@Z0123456789abcdefr�r�r cSsg|]}t|��qSrr�)rrr�rrrrsb
scsg|]}|�jkr|�qSr�r��rrr�r)rrrsc
s
�cs*g|]"}d|kr�jkrnq|�qS�r�r�r�r)rrrse
s

�cSsg|]}|dkr|�qSr�rr�rrrrsg
s)r�rr�r�r�r�r�r�r�r�r�r�r�r�r�
gc_collectr[r�r�)
r&r�r�Zobjects�writerr
Z
reconstructedr�Zchunk_sizesZlarge_sizesZmedium_sizesZsmall_sizesZ
chunk_sizerr)r�+test_framed_write_sizes_with_delayed_writer2
s@	
��
�
�z?AbstractPickleTests.test_framed_write_sizes_with_delayed_writercCszGdd�d�attjd�D]X}tjtjjtjjjfD]<}|j||d��$|�|�	||��}|�
||�W5QRXq6qdS)Nc@seZdZGdd�d�ZdS)�Nestedc@seZdZGdd�d�ZdS)zNested.Ac@seZdZGdd�d�ZdS)z
Nested.A.Bc@seZdZdS)zNested.A.B.CNrPrrrrrDy
srDN)r0r1r2rDrrrrr;x
sr;N)r0r1r2r;rrrr�Aw
sr�N)r0r1r2r�rrrrr�v
sr�r)r�rw)r�r�rr�r�r;rDr�r�r�r�)r&r�rwrrrr�test_nested_namest
sz%AbstractPickleTests.test_nested_namesc
CstGdd�d�atjtjt_dt_ttjd�D]:}|j	|d��$|�
|�t|��}|�|t�W5QRXq0t`dS)Nc@seZdZdS)�	RecursiveNrPrrrrr��
sr�zRecursive.mod.Recursiverr_)
r�rx�modulesr1�modr2r�rr�r�r�r�r�)r&r�rrrr�test_recursive_nested_names�
sz/AbstractPickleTests.test_recursive_nested_namescCs�Gdd�d�atjtjt�jtjjtjjt��jf}tjtftjjtjff}tt	j
d�D]�}|D]@}|j||d��(|�|�
||��}|�|�|��W5QRXqb|D]N\}}|�}|j||d��,|�|�
||��}|�||�||��W5QRXq�qZdS)Nc@s:eZdZedd��Zedd��Zdd�ZGdd�d�Zd	S)
�
PyMethodsTestcSsdS)N�cheeserrrrrr��
szPyMethodsTest.cheesecSs|tkst�dS)N�wine)r��AssertionError�ryrrrr��
szPyMethodsTest.winecSst|t�st�dS)N�biscuits)r�r�r�r)rrrr��
szPyMethodsTest.biscuitsc@s0eZdZdZedd��Zedd��Zdd�ZdS)	zPyMethodsTest.NestedzNested classcSsdS)N�ketchuprrrrrr��
szPyMethodsTest.Nested.ketchupcSs|tjkst�dS)N�maple)r�r�r�r�rrrr��
szPyMethodsTest.Nested.maplecSst|tj�st�dS)N�pie)r�r�r�r�r)rrrr��
szPyMethodsTest.Nested.pieN)	r0r1r2r:�staticmethodr�r�r�r�rrrrr��
s

r�N)	r0r1r2r�r�r�r�r�r�rrrrr��
s

r�r�r��method)r�r�r�r�r�r�r�r�r�rr�r�r�r�r�)r&Z
py_methodsZpy_unbound_methodsr�r�rryrwrrr�test_py_methods�
s*�	�z#AbstractPickleTests.test_py_methodscCsGdd�dt�adjdftjdfdddgjd	ftjdddgffddhjd
ftjddhdfftj	dft
jdftdddg�jd
ftjtdddg�dfft�
d
�jdftj
jt�
d
�dfff}ttjd�D]R}|D]H\}}|j||d��,|�|�||��}|�||�||��W5QRXq�q�dS)Nc@seZdZGdd�de�ZdS)�Subclassc@seZdZdS)zSubclass.NestedNrPrrrrr��
sr�N)r0r1r2rWr�rrrrr��
sr��abcd)r�)r�r�rr�r rr�))rZr)r[r�)sabcr�Zsweet)r-r-r�)r�r��indexrW�__len__r��__contains__r�rbr�r�	maketrans�countr�r�rr�r�r�r�r�)r&Z	c_methodsr�r�r'rrrr�test_c_methods�
s&�z"AbstractPickleTests.test_c_methodscCs�tdd�ddfttd�ddftjddftjd	d	ft�d
dft�	�dd
ft�
�ddft��ddfg}|D]t\}}}td�D]`}|jt
|�|d��D|�||�}|�d||f��|�|�t
|�|��t
|��W5QRXqxqfdS)Nrr�__builtin__�xrangeZ123�	itertools�imapr$r&�
exceptionsr�r(�IterableUserDict�UserListr'�defaultdictr )r_r�zc%s
%s)r�r�r�r#r$r%r&r�r'r(r�r�r�r_r�r�r�r�r�)r&Ztests�valr�rcr�r
rrr�test_compat_pickle�
s


�
z&AbstractPickleTests.test_compat_picklec
Cs�dd�}tdtjd�D]2}|�ttjf��t�|�||��W5QRXq|`	tdtjd�D]2}|�ttjf��t�|�||��W5QRXq`|j
|_tdtjd�D]2}|�ttjf��t�|�||��W5QRXq�dS)NcSsdSrrrrrrr��
sz6AbstractPickleTests.test_local_lookup_error.<locals>.frr)r�rr�r��AttributeErrorr|rr�r�r1r2r0�r&r�r�rrr�test_local_lookup_error�
sz+AbstractPickleTests.test_local_lookup_errorccs�d}t|�Vt|�Vtdk	r�t|�}tj|dd�}dtjfD]>}t|dd|d�Vt|ddd	|d
�Vt|ddd|d
�Vq@dS)N�abcdefgh�little)�	byteorderrr;)r�)rrr�r�)r!r�r#)rrr�r�r�r")rfr�r�r�r��
from_bytesr�r�)r&Z
bytestringr�rRr�rrr�buffer_like_objectss&

���z'AbstractPickleTests.buffer_like_objectscCs|��D]�}tdtjd�D]�}|�||�}|jrF|dkrF|�d|�|�ttj	|�d�|dkr�|�ttj
|�|jrzdnd�|�ttj|�|jr�dnd�dd�}|j|||d�}|�||�|�
|�}|�||�|�t|�t|��|�||�qqdS)Nrrrhr�cSsdS�NTr�rwrrr�buffer_callback0szAAbstractPickleTests.test_in_band_buffers.<locals>.buffer_callback�r�)r�r�rr�r�r}r�r�r�NEXT_BUFFER�SHORT_BINBYTESr|r�r�r�r�r_)r&rwr�r�r��data2r�rrr�test_in_band_buffers s,���
z(AbstractPickleTests.test_in_band_bufferscs�|��D�]�}tdd�D],}|�t��|j||gjd�W5QRXqtdtjd�D�]R}g��fdd�}|j|||d�}|�d|�|�	t
tj|�d�|�	t
tj|�d�|�	t
tj
|�d�|�	t
tj|�|jr�dnd�|jr�|�	t�d�d�|�tj��|�|�W5QRX|j|�d�}|j�rB|�||�n |�t|�t|��|�	||�|j|t��d�}|j�r�|�||�qV|�t|�t|��|�	||�qVqdS)	Nrrhr�rcs��|���Sr)r�r�)r���buffersrrr�IrKz6AbstractPickleTests.test_oob_buffers.<locals>.<lambda>r�r�)r�r�r�r�r�r�rr�r�r�rr�r�r��READONLY_BUFFERr|r}rlr�r�rr�r_�iter)r&rwr�r�r�r�rr�r�test_oob_buffers?sB���z$AbstractPickleTests.test_oob_bufferscCsttd�}tdtjd�D]V}g}|j}|j|||d�}tt|�}|j||d�}|�	t
|�t
|��|�||�qdS�N�foobarrhrr�r�)rfr�rr�r�r�r�rr�r�r_r�)r&rwr�r�r�r�r�rrr�%test_oob_buffers_writable_to_readonlyis
z9AbstractPickleTests.test_oob_buffers_writable_to_readonlyc
CsBt�d�}tdd�D](}|�tj��|�||�W5QRXqdS)Nr�rrh)rrkr�r��PickleErrorr�)r&r�r�rrr�test_picklebuffer_errorvs
z+AbstractPickleTests.test_picklebuffer_errorc	Cs<dd�}t�d�}|�t��|j|d|d�W5QRXdS)NcSsdddSr�rr�rrrr�~szGAbstractPickleTests.test_buffer_callback_error.<locals>.buffer_callbackr�rhr�)rrkr��ZeroDivisionErrorr�)r&r�r�rrr�test_buffer_callback_error}s
z.AbstractPickleTests.test_buffer_callback_errorc
Cs�t�d�}tdtjd�D]b}|j||gjd�}|�t��|j|t	�d�W5QRX|�tj
��|j|gd�W5QRXqdSr�)rrkr�r�r�r�r�r*r�r�r�)r&r�r�r�rrr�test_buffers_error�s
z&AbstractPickleTests.test_buffers_errorcCs8tdtjd�D]"}|jd|dd�}|j|dd�}qdS)Nrhrr�r�)r�rr�r�r�)r&r�Zdata_pickledr�rrr�+test_inband_accept_default_buffers_argument�sz?AbstractPickleTests.test_inband_accept_default_buffers_argumentNzTest needs Numpycs��fdd���fdd�����fdd�}t�d�}||�||ddd��t�d	��d
�}||�||j�||ddd��dS)Ncs&tj�||���|jj|jj�dSr)�np�testing�assert_equalr��ctypesr��r!r�r)rr�
check_no_copy�sz=AbstractPickleTests.test_buffers_numpy.<locals>.check_no_copycs&tj�||���|jj|jj�dSr)rrr	r�r
r�rr)rr�
check_copy�sz:AbstractPickleTests.test_buffers_numpy.<locals>.check_copycs�tdtjd�D]$}��||�}��|�}�||�qtdtjd�D]0}dd�}�j|||d�}��|�}�||�qFtdtjd�D]R}g}|j}�j|||d�}�j||d�}|jjs�|jjrЈ||�q��||�q�dS)NrrrhcSsdSr�r)r�rrrr��rKzMAbstractPickleTests.test_buffers_numpy.<locals>.check_array.<locals>.<lambda>r�r�)	r�rr�r�r�r�r�r}r~)�arrr�r�r�r�r��r
rr&rr�check_array�s"

z;AbstractPickleTests.test_buffers_numpy.<locals>.check_arrayr"r��r$)rZarangeZreshape�T)r&rrrrr�test_buffers_numpy�s

z&AbstractPickleTests.test_buffers_numpy)�r0r1r2Z	optimizedr�r�r�r�r�r�r�r"r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr	r
rrrrrrr r.r2r5r6r=rBrErKrMrOrRrWrYr\rdrgrirkrnrqrsrurwrrzr}r�r�r�r�r�r�r�r�r�r�r�rZskip_if_pgo_taskr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�unittestZskipIfrrrrrrr��s�





	'		
					



	
/
 *
A
1#*
r�c@szeZdZeeddd�dd��Zeeddd�dd��Zeeddd�d	d
��Zeeddd�dd
��Z	eeddd�dd��Z
dS)�BigmemPickleTestsg������@F)�sizeZmemuse�dry_runcCspdd|>}zXtD]N}|dkr q|j|d��.|�ttf��|j||d�W5QRXW5QRXqW5d}XdS)Nrr�r�r_r�)r�r�r�r�r�r�)r&rr�r�rrr�test_huge_long_32b�s(z$BigmemPickleTests.test_huge_long_32bg@c
Cs�d|d}z�tD]|}|dkr q|j|d��\zN|j||d�}tjt�dt|��}|�|�}|�	|||t|�|��W5d}XW5QRXqW5d}XdS)N�abcdr!r r_r�r�)
r�r�r�rr�r�r�r�r�r��r&rr�r�r
�headerZ
data_startrrr�test_huge_bytes_32b�s$�
�z%BigmemPickleTests.test_huge_bytes_32bcCs�d|d}z�tD]�}|dkr q|j|d���|dkrj|�ttf��|j||d�W5QRXW5QR�qzN|j||d�}tjt�	dt
|��}|�|�}|�|||t
|�|��W5d}XW5QRXqW5d}XdS)Nsacbdr!r r_r��<Q)
r�r�r�r�r�r�rr�r�r�r�r�r�rrrr�test_huge_bytes_64b�s,�
�z%BigmemPickleTests.test_huge_bytes_64br�c
Cs�d|d}z�tD]�}|dkr q|j|d���zv|j||d�}tjt�dt|��}|�d�}|�	|||t|�|��|�	|�
d�td�|�d�t|��W5d}XW5QRXqW5d}XdS)Nr�r!rr_r�r�r)r�r�r�rr�r�r�r�r�r��rindexrrrr�test_huge_str_32b
s.�
���z#BigmemPickleTests.test_huge_str_32bcCsd|d}z�tD]�}|dkr q|j|d���|dkrj|�ttf��|j||d�W5QRXW5QR�qzv|j||d�}tjt�	dt
|��}|�d�}|�|||t
|�|��|�|�
d�t
d�|�d�t
|��W5d}XW5QRXqW5d}XdS)Nr�r!rr_r�rr)r�r�r�r�r�r�rr�r�r�r�r�r�rrrrr�test_huge_str_64b%s6�
���z#BigmemPickleTests.test_huge_str_64bN)r0r1r2rr	rrr
rr r!rrrrr�s



rc@seZdZdZdZdd�ZdS)rlz4No __reduce_ex__ here, but inheriting it from objectrcCsd|_tdfS)Nrr)rmrlr)rrrrSFszREX_one.__reduce__N�r0r1r2r:rmrSrrrrrlCsrlc@seZdZdZdZdd�ZdS)roz1No __reduce__ here, but inheriting it from objectNcCs||_tdfSrM�rpro�r&r�rrrroMszREX_two.__reduce_ex__�r0r1r2r:rprorrrrroJsroc@s eZdZdZdd�Zdd�ZdS)rrNcCs||_tdfSrMr#r$rrrroSszREX_three.__reduce_ex__cCstd��dS)Nz#This __reduce__ shouldn't be called)rr)rrrrSVszREX_three.__reduce__)r0r1r2rprorSrrrrrrQsrrc@seZdZdZdZdd�ZdS)rtz(Calling base class method should succeedNcCs||_t�||�Sr)rpr�ror$rrrro\szREX_four.__reduce_ex__r%rrrrrtYsrtc@seZdZdZdZdd�ZdS)rvz-This one used to fail with infinite recursionrcCsd|_t�|�Sr�)rmr�rSr)rrrrScszREX_five.__reduce__Nr"rrrrrv`srvc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)r�z]This class is used to check the 4th argument (list iterator) of
    the reduce protocol.
    NcCs|dk	r|ng|_dSrr�)r&r�rrrr9kszREX_six.__init__cCst|�t|�ko|j|jkSr)r_r�rFrrrrHmszREX_six.__eq__cCs|j�|�dSr)r�r�)r&�itemrrrr�oszREX_six.appendcCst|�ddt|j�dfSrM)r_r�r�r)rrrrSqszREX_six.__reduce__)N)r0r1r2r:r9rHr�rSrrrrr�gs

r�c@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)r�z]This class is used to check the 5th argument (dict iterator) of
    the reduce protocol.
    NcCs|dk	r|ni|_dSrr�)r&r�rrrr9xszREX_seven.__init__cCst|�t|�ko|j|jkSr)r_r�rFrrrrHzszREX_seven.__eq__cCs||j|<dSrr�)r&r�rRrrr�__setitem__|szREX_seven.__setitem__cCst|�dddt|j���fSrM)r_r�r�r�r)rrrrS~szREX_seven.__reduce__)N)r0r1r2r:r9rHr'rSrrrrr�ts

r�c@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)r�zUThis class is used to check the 3th argument (state) of
    the reduce protocol.
    NcCs
||_dSr�r��r&r�rrrr9�szREX_state.__init__cCst|�t|�ko|j|jkSr�r_r�rFrrrrH�szREX_state.__eq__cCs
||_dSrr(r)rrr�__setstate__�szREX_state.__setstate__cCst|�d|jfSrMr*r)rrrrS�szREX_state.__reduce__)N)r0r1r2r:r9rHr+rSrrrrr��s

r�c@seZdZdZdS)r>rN�r0r1r2r:rrrrr>�sr>c@seZdZdZdS)�MyFloatg�?Nr,rrrrr-�sr-c@seZdZdZdS)�	MyComplexy�?Nr,rrrrr.�sr.c@seZdZdZdS)�MyStrr4Nr,rrrrr/�sr/c@seZdZdZdS)�	MyUnicodeu	hello ሴNr,rrrrr0�sr0c@seZdZdZdS)r�r%Nr,rrrrr��sr�c@seZdZdddgZdS)r�rr�r Nr,rrrrr��sr�c@seZdZddd�ZdS)r�rr�rYNr,rrrrr��sr�c@seZdZddhZdS)r�rZr[Nr,rrrrr��sr�c@seZdZeddh�ZdS)r�rZr[N)r0r1r2r�r:rrrrr��sr�c@seZdZdgZdS)rjr�N)r0r1r2r�rrrrrj�srjc@seZdZdd�Zdd�ZdS)rCcOstd��dS)Nz3SimpleNewObj.__init__() didn't expect to get called)r*r�rrrr9�szSimpleNewObj.__init__cCst|�t|�ko|j|jkSr)r�rErFrrrrH�szSimpleNewObj.__eq__N)r0r1r2r9rHrrrrrC�srCc@seZdZdd�ZdS)rfcCsd|dfS)N�%Xr�rr)rrr�__getnewargs__�szComplexNewObj.__getnewargs__N)r0r1r2r2rrrrrf�srfc@seZdZdd�ZdS)rhcCsd|fddifS)Nr1�baser�rr)rrr�__getnewargs_ex__�sz!ComplexNewObjEx.__getnewargs_ex__N)r0r1r2r4rrrrrh�srhc@seZdZdd�ZdS)rxcCs
|jdSr)r�)r&r�rrr�__getattr__�szBadGetattr.__getattr__N)r0r1r2r5rrrrrx�srxc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�AbstractPickleModuleTestsc	Cs:ttd�}z|��|�t|jd|�W5t�t�XdS�Nrf�{�r|rr�unlink�closer�r�r��r&r�rrr�test_dump_closed_file�s

z/AbstractPickleModuleTests.test_dump_closed_filec	Cs:ttd�}z|��|�t|jd|�W5t�t�XdSr7r9r<rrr�test_load_closed_file�s

z/AbstractPickleModuleTests.test_load_closed_filecCsBt��}didg}|�||�|�d�|�|�}|�||�dS)Nr8�|r)r,r4r�r.�loadr�)r&�streamr�rrrr�test_load_from_and_dump_to_file�s


z9AbstractPickleModuleTests.test_load_from_and_dump_to_filecCs|�tjd�dSrg)r�rr�r)rrr�test_highest_protocol�sz/AbstractPickleModuleTests.test_highest_protocolcCs^t��}|�d|d�|jd|dd�|�dd�|jddd�|�|d�|j|dd�dS)Nr8r�)�filernr�)r,r4r�r��Picklerr<rrr�test_callapi�sz&AbstractPickleModuleTests.test_callapic	CsFttd�}z"tD]}|�t|jd||�qW5|��t�t�XdS)N�wr8)	r|rr;rr:r�r�r*r�r�rrr�test_dump_text_file�s
z-AbstractPickleModuleTests.test_dump_text_filecCs(t�d�}|�ttjtjf|j|�dS)NsX''.)	r,r4r�rdr�r.rr�r@)r&r�rrr�test_incomplete_input�s
z/AbstractPickleModuleTests.test_incomplete_inputcCsNGdd�d|j�}Gdd�d|j�}|�tj|�jd�|�tj|�j�dS)Nc@seZdZdd�ZdS)z;AbstractPickleModuleTests.test_bad_init.<locals>.BadPicklercSsdSrrr)rrrr9
rKzDAbstractPickleModuleTests.test_bad_init.<locals>.BadPickler.__init__NrKrrrr�
BadPickler
srJc@seZdZdd�ZdS)z=AbstractPickleModuleTests.test_bad_init.<locals>.BadUnpicklercSsdSrrr)rrrr9
rKzFAbstractPickleModuleTests.test_bad_init.<locals>.BadUnpickler.__init__NrKrrrr�BadUnpickler
srKr)rE�	Unpicklerr�rr|r�r�r@)r&rJrKrrr�
test_bad_init
sz'AbstractPickleModuleTests.test_bad_initc	
Cs�td�}tdd�D]*}|�t��|||gjd�W5QRXqtdtjd�D]t}g}|j}||||d�}|�d|�|�t	|d�d�|�tj
��||�W5QRX|||d�}|�||�qNdS)Nsfoorrh)rnr�rr�)rfr�r�r�r�rr�r�r�rlr�r�)	r&r�r�rwr�r�r�r�r�rrr�check_dumps_loads_oob_buffers

s$��z7AbstractPickleModuleTests.check_dumps_loads_oob_bufferscCs|�|j|j�dSr)rNr�r�r)rrr�test_dumps_loads_oob_buffers%
sz6AbstractPickleModuleTests.test_dumps_loads_oob_bufferscs(�fdd�}�fdd�}��||�dS)Ncs t��}�j||f|�|��Sr)r,r4r�r5)rwr�r�r)rrr�+
szCAbstractPickleModuleTests.test_dump_load_oob_buffers.<locals>.dumpscst�|�}�j|f|�Sr)r,r4r@)r�r�r�r)rrr�0
s
zCAbstractPickleModuleTests.test_dump_load_oob_buffers.<locals>.loads)rN)r&r�r�rr)r�test_dump_load_oob_buffers)
sz4AbstractPickleModuleTests.test_dump_load_oob_buffersN)r0r1r2r=r>rBrCrFrHrIrMrNrOrPrrrrr6�s
	r6c@s$eZdZdd�Zdd�Zdd�ZdS)�AbstractPersistentPicklerTestscCsNt|t�r,|ddkr,|jd7_t|�S|dkrF|jd7_dSdSdS)Nr�rr�test_false_valuer�)r�r��id_countrW�false_count)r&r�rrr�
persistent_id=
sz,AbstractPersistentPicklerTests.persistent_idcCsD|s|jd7_dS|jd7_t|�}|ddks<t�|SdS)NrrRr�r)�load_false_count�
load_countr�r�)r&Zoidr�rrr�persistent_loadG
sz.AbstractPersistentPicklerTests.persistent_loadc	Cs�ttd��dg}tD]n}d|_d|_d|_d|_|�|�|�	||��|�|�|jd�|�|jd�|�|jd�|�|jd�qdS)NrTrRrrhr)
r�r�r�rSrTrVrWr�r�r�)r&�Lr�rrr�test_persistenceQ
sz/AbstractPersistentPicklerTests.test_persistenceN)r0r1r2rUrXrZrrrrrQ7
s

rQc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�&AbstractIdentityPersistentPicklerTestscCs|Srr)r&rwrrrrUa
sz4AbstractIdentityPersistentPicklerTests.persistent_idcCs|Srr)r&�pidrrrrXd
sz6AbstractIdentityPersistentPicklerTests.persistent_loadcCs2|�|�||��}|�|t|��|�||�dSr)r�r�r�r_r�)r&rwr�rrrr�_check_return_correct_typeg
szAAbstractIdentityPersistentPicklerTests._check_return_correct_typecCsDtD]:}|dkr|�dd�qddddtfD]}|�||�q,qdS)Nrr�sabc
zabc
r�g*\��(��)r�r]rW)r&r�rwrrr�test_return_correct_typel
s
z?AbstractIdentityPersistentPicklerTests.test_return_correct_typecCsBd}|�tj|j|d�tj|�d�d}|�tj|j|�dS)Nu∅rrgr�)r�rr|r��PERSIDr�r�r�)r&Z
non_ascii_strr
rrr�test_protocol0_is_ascii_onlyu
szCAbstractIdentityPersistentPicklerTests.test_protocol0_is_ascii_onlyN)r0r1r2rUrXr]r^r`rrrrr[_
s
	r[c@sjeZdZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�#AbstractPicklerUnpicklerObjectTestsNcCs|js
t�|jst�dSr)�
pickler_classr��unpickler_classr)rrrr��
s
z)AbstractPicklerUnpicklerObjectTests.setUpcCs�dddg}tD]�}t��}|�||�}|�|�|��}|�d�|��|�|�|��}|��|�d�|��|�|�|��}|�	||�|�
||�qdS�N�abcdefg�,r)r�r,r4rbr�r5r.�truncate�
clear_memor�r�)r&r�r�r�r��
first_pickledZsecond_pickledZ
third_pickledrrr�test_clear_pickler_memo�
s"





z;AbstractPicklerUnpicklerObjectTests.test_clear_pickler_memocCsjdddg}t��}|�|�}|�|�|��}t��}|�|�}|j|_|�|�|��}|�||�dS�Nrerf)r,r4rbr�r5�memor�)r&r�r�r�ri�primed�primed_pickledrrr�test_priming_pickler_memo�
s




z=AbstractPicklerUnpicklerObjectTests.test_priming_pickler_memoc
Cs�dddg}t��}|�|�}|�|�|��}t��}|�|�}|j|_|�|�|��}|�t�|��}|��}|�||�|�t�|��}|j|_|��}	|j�	�|�|	|�|�
|	|k�dSrk)r,r4rbr�r5rlrcr@r��clearr�)
r&r�r�r�rirmrn�	unpicklerZunpickled_data1Zunpickled_data2rrr�test_priming_unpickler_memo�
s&





z?AbstractPicklerUnpicklerObjectTests.test_priming_unpickler_memocCs�dddg}t��}|�|�}|�|�|��}dddg}t��}|�|�}|�|�|��}t��}|�|�|�d�|�|�}|�|�	�|�|�d�|�
�|�|�|�d�|�|�	�|�dSrd)r,r4rbr�r5r8r.rcr�r@rg)r&�data1r�r�Zpickled1r�Zpickled2rqrrr�test_reusing_unpickler_objects�
s(











zBAbstractPicklerUnpicklerObjectTests.test_reusing_unpickler_objectsT�r*c
Cs�tD]�}|j|d���dd�td�D�dtg}|�}|j||d�}|�|�|��}d}|||�}|�|�}	t|�D]<}
|r�|��}|�	|	�
�|�|rx|�	|��|t|��qx|�t|	j
�W5QRXqdS)Nr_cSsg|]}|t|�f�qSrrVrqrrrrs�
szSAbstractPicklerUnpicklerObjectTests._check_multiple_unpicklings.<locals>.<listcomp>i�sabcder�rh)
r�r�r�r�rbr�r5rcr/r�r@r�rd)r&Zioclassr*r�rsr�r�r
r�rqr�r�rrr�_check_multiple_unpicklings�
s"

z?AbstractPicklerUnpicklerObjectTests._check_multiple_unpicklingscCs|�tj�dSr)rvr,r4r)rrr�"test_multiple_unpicklings_seekableszFAbstractPicklerUnpicklerObjectTests.test_multiple_unpicklings_seekablecCs|jtdd�dS�NFru)rvr#r)rrr�$test_multiple_unpicklings_unseekableszHAbstractPicklerUnpicklerObjectTests.test_multiple_unpicklings_unseekablecCs|jtdd�dSrx)rvr3r)rrr�!test_multiple_unpicklings_minimalszEAbstractPicklerUnpicklerObjectTests.test_multiple_unpicklings_minimalcCsxttd��}tD]b}tdd�D]R}tjt��|d�}|j||d�}|�|�|�d�|�	|�}|�
|��|�qqdS)NrTr�)Zbuffer_sizer�r)r�r�r�r,�BufferedRandomr4rbr�r.rcr�r@)r&r�r�Zbuf_sizer�r�rqrrr�"test_unpickling_buffering_readline
s


zFAbstractPicklerUnpicklerObjectTests.test_unpickling_buffering_readline)r0r1r2rbrcr�rjrorrrtrvrwryrzr}rrrrra|
s raZreduce_Ac@seZdZdd�ZdS)rcCs
ttffSr)rWrr)rrrrS szAAA.__reduce__Nr{rrrrrsrc@seZdZdd�Zdd�ZdS)�BBBcCs
d|_dS)Nzsome attribute�rZr)rrrr9$szBBB.__init__cCs
d|_dS)N�BBB.__setstate__rr)rrrr+)sr�N)r0r1r2r9r+rrrrr~#sr~cCs
d|_dS)atCustom state setter for BBB objects

    Such callable may be created by other persons than the ones who created the
    BBB class. If passed as the state_setter item of a custom reducer, this
    allows for custom state setting behavior of BBB objects. One can think of
    it as the analogous of list_setitems or dict_setitems but for foreign
    classes/functions.
    �custom state_setterNr)rwr�rrr�setstate_bbb-s	r�c@seZdZdZdd�ZdS)�AbstractCustomPicklerClassz<Pickler implementing a reducing hook using reducer_override.cCsLt|dd�}|dkrtdfS|dkr,tdfS|dkr8dS|dkrHtd	��tS)
Nr0r�)rh�MyClass)�some str�gF�h�The reducer just failed)r�r�rWr�r�)r&rwZobj_namerrr�reducer_override<sz+AbstractCustomPicklerClass.reducer_overrideN)r0r1r2r:r�rrrrr�:sr�c@s"eZdZdd�Zejdd��ZdS)�AbstractHookTestscCs�dd�}dd�}dd�}Gdd�d�}td	tjd
�D]�}|j|d���t��}|�||�}|�||tj	g�t�
|���\}}	}
|�|d�|�|	d
�|�
|
tj	�|�tj��|�|�W5QRX|�td��|�|�W5QRXW5QRXq6dS)NcSsdSrrrrrrr�Xsz.AbstractHookTests.test_pickler_hook.<locals>.fcSsdSrrrrrrr�[sz.AbstractHookTests.test_pickler_hook.<locals>.gcSsdSrrrrrrr�^sz.AbstractHookTests.test_pickler_hook.<locals>.hc@seZdZdS)z4AbstractHookTests.test_pickler_hook.<locals>.MyClassNrPrrrrr�asr�rrr_rhr�r�)r�rr�r�r,r4rbr��math�logr�r5r�r�r�r|ZassertRaisesRegexr�)r&r�r�r�r�r��bior�new_fZsome_strZmath_logrrr�test_pickler_hookSs(�z#AbstractHookTests.test_pickler_hookc
Cs�tdtjd�D]v}|j|d��`dd�}t�|�}t��}|�||�}|�	|�t�
|���}|dkslt�~~|�
|��W5QRXqdS)Nrrr_cSsdSrrrrrrr��szEAbstractHookTests.test_reducer_override_no_reference_cycle.<locals>.frh)r�rr�r�r?�refr,r4rbr�r�r5r�r�)r&r�r��wrr�rr�rrr�(test_reducer_override_no_reference_cycle{s

z:AbstractHookTests.test_reducer_override_no_reference_cycleN)r0r1r2r�rZcpython_onlyr�rrrrr�Rs(r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AbstractDispatchTableTestsc	CsDt��}|�|d�}|�t��|jW5QRX|�t|d��dS)Nr�dispatch_table)r,r4rbr�r�r�rFr�)r&r�rrrr�test_default_dispatch_table�s
z6AbstractDispatchTableTests.test_default_dispatch_tablecs@����G�fdd�d�j��d���fdd�	}��|��dS)NcseZdZ�ZdS)zGAbstractDispatchTableTests.test_class_dispatch_table.<locals>.MyPicklerN)r0r1r2r�r)�dtrr�	MyPickler�sr�cs2t��}�||�}��|j��|�|�|��Sr)r,r4r�r�r�r5�rwrnr�r�r�r�r&rrr��s


zCAbstractDispatchTableTests.test_class_dispatch_table.<locals>.dumps)N)�get_dispatch_tablerb�_test_dispatch_table�r&r�rr�r�test_class_dispatch_table�sz4AbstractDispatchTableTests.test_class_dispatch_tablecs(����d��fdd�	}��|��dS)Ncs:t��}��||�}�|_��|j��|�|�|��Sr)r,r4rbr�r�r�r5r��r�r&rrr��s
zFAbstractDispatchTableTests.test_instance_dispatch_table.<locals>.dumps)N)r�r�r�rr�r�test_instance_dispatch_table�sz7AbstractDispatchTableTests.test_instance_dispatch_tablecs��fdd�}dd�}d}|�||�|�|�||�|�d��fdd�}||t<|�||���|�||�|�t�}t�}|�||�t�|�||�t�|�||�t�|�||�t�||t<|�||�t�|�||���|�||�t�|�||�t�d	��fd
d�}	|	|t<|t=|�||���|�||�t�|�||�t�|�||�t�|�||�jd�d
d�}
|
|t<|�||�jd�dS)Ncst��|d��S�Nr)rr�r�r�rr�custom_load_dump�szIAbstractDispatchTableTests._test_dispatch_table.<locals>.custom_load_dumpcSst�t�|d��Sr�)rr�r�r�rrr�default_load_dump�szJAbstractDispatchTableTests._test_dispatch_table.<locals>.default_load_dumpy�?@�reduce_1cs
t�ffSrrVr�)�REDUCE_1rrr��szAAbstractDispatchTableTests._test_dispatch_table.<locals>.reduce_1�reduce_2cs
t�ffSrrVr�)�REDUCE_2rrr��szAAbstractDispatchTableTests._test_dispatch_table.<locals>.reduce_2r�cSstd|jddtfSrM)r~rEr�r�rrr�
reduce_bbb�szCAbstractDispatchTableTests._test_dispatch_table.<locals>.reduce_bbbr�)r��complexrr~rr�rZ)r&r�r�r�r�r�r�rZr[r�r�r)r�r�r�rr��sB
z/AbstractDispatchTableTests._test_dispatch_tableN)r0r1r2r�r�r�r�rrrrr��sr�r�zDATA{0} = (r�z	    {0!r}r�z# Disassembly of DATA{0}zDATA{0}_DIS = """\z""")�r'r=r%r,r#rtr�rrrvr�rxr~rr?�textwraprZhttp.cookiesrr��ImportError�testrZtest.supportrrrrr	r
rrr
rrZnumpyrZ
skipUnlessr�r�r�r�r�rrr"r4r#r�r3r;rDrIrLrOrQrTr1r�rUrXr_r\r]r^rarlrfrr�r�r�r�r�r�r�Z	DATA2_DISr�Z	DATA3_DISr�Z	DATA4_DISr�r�r�r��ArithmeticErrorr�r�r��BufferError�BytesWarning�DeprecationWarningrd�EnvironmentErrorr��FloatingPointError�
FutureWarning�
GeneratorExit�IOError�
ImportWarning�IndentationError�
IndexErrorr�KeyboardInterrupt�LookupError�MemoryError�	NameErrorr$�OSErrorr��PendingDeprecationWarning�ReferenceErrorry�RuntimeWarning�
StopIteration�SyntaxError�
SyntaxWarning�SystemError�
SystemExit�TabErrorr*�UnboundLocalError�UnicodeError�UnicodeWarning�UserWarningr��Warningrr�r�r�r�ZTestCaser�r�rrlrorrrtrvr�r�r�r>�floatr-r�r.rWr/r0r�r�r�r�rbr�r�r�r�r�r8rjrCrfrhrxr6rQr[rarrr~r�r�r�r�r0r�r!r�r�rr�rrr��jr[rrrr�<module>s�
0
�	
N�S�A�:�:�
C�0g0

�k("

Bk


Zerion Mini Shell 1.0