B
    u9a ° ã            ,   @   sª  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZ d dlmZ e e
j dk d¡Z!e"ej#d	 ƒZ$d
d„ Z%dd„ Z&G dd„ dej'ƒZ(G dd„ dƒZ)G dd„ dƒZ*G dd„ de*ƒZ+G dd„ de*ƒZ,G dd„ de-ƒZ.G dd„ de-ƒZ/d dl0Z0e*e0_*de*_1e+e0_+de+_1e,e0_,de,_1e.e0_.de._1e/e0_/de/_1G dd„ de2ƒZ3G dd „ d e*ƒZ4G d!d"„ d"e5ƒZ6G d#d$„ d$e-e6d%Z7G d&d'„ d'e5ƒZ8d(d)„ Z9d*Z:d+Z;d,Z<d-Z=d.Z>d/Z?d0Z@d1ZAd2ZBd3ZCd4ZDd5ZEd6ZFd7ZGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe[e\e]e^e_e`eaebecedeeefegeheiejekelemeneoepeqeresf,Ztd8Zud9Zvd:d;„ ZwG d<d=„ d=ejxƒZyG d>d?„ d?ejxƒZzG d@dA„ dAejxƒZ{G dBdC„ dCe-ƒZ|G dDdE„ dEe-ƒZ}G dFdG„ dGe-ƒZ~G dHdI„ dIe-ƒZG dJdK„ dKe-ƒZ€G dLdM„ dMe-ƒZG dNdO„ dOe-ƒZ‚G dPdQ„ dQe2ƒZƒG dRdS„ dSe„ƒZ…G dTdU„ dUe†ƒZ‡G dVdW„ dWeˆƒZ‰G dXdY„ dYeˆƒZŠG dZd[„ d[e‹ƒZŒG d\d]„ d]eƒZŽG d^d_„ d_eƒZG d`da„ dae‘ƒZ’G dbdc„ dce“ƒZ”eƒe…e‡e‰eŠeŒeŽee’e”g
Z•G ddde„ deeŽƒZ–G dfdg„ dge2ƒa—G dhdi„ dit—ƒZ˜G djdk„ dkt—ƒZ™G dldm„ dmƒZšG dndo„ doejxƒZ›G dpdq„ dqejxƒZœG drds„ dsejxƒZG dtdu„ duejxƒZždvZŸG dwdx„ dxe-ƒZ G dydz„ dze-ƒZ¡G d{d|„ d|ejxƒZ¢e£dkr¦d d}lm¤Z¤ ewƒ Z¥x°e"ej#d	 ƒD ]žZ¦e §e¥e¦¡Z¨e©d~ ªe¦¡ƒ x<e"d e«e¨ƒdƒD ](Z¬e­e¨e¬e¬d … ƒZ®e©d€ ªe®¡ƒ q4W e©dƒ e©ƒ  e©d‚ ªe¦¡ƒ e©dƒ ªe¦¡ƒ e¤e¨ƒ e©d„ƒ e©ƒ  qW dS )…é    N)Údedent)ÚSimpleCookie)Úsupport)	Ú
TestFailedÚTESTFNÚrun_with_localeÚ
no_tracingÚ_2GÚ_4GÚ
bigmemtestÚreap_threadsÚforget)Úbytes_typesl        z(test is only meaningful on 32-bit buildsé   c             C   s2   x,t  |¡D ]\}}}|j|  d¡krdS qW dS )Nzlatin-1TF)ÚpickletoolsÚgenopsÚcodeÚdecode)r   ÚpickleÚopÚdummy© r   ú"/usr/lib/python3.7/pickletester.pyÚopcode_in_pickle$   s    r   c             C   s:   d}x0t  |¡D ]"\}}}|j|  d¡kr|d7 }qW |S )Nr   zlatin-1r   )r   r   r   r   )r   r   Únr   r   r   r   r   Úcount_opcode+   s
    r   c               @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚUnseekableIOc             G   s   t ‚d S )N)ÚNotImplementedError)ÚselfÚargsr   r   r   Úpeek4   s    zUnseekableIO.peekc             C   s   dS )NFr   )r   r   r   r   Úseekable7   s    zUnseekableIO.seekablec             G   s
   t j‚d S )N)ÚioÚUnsupportedOperation)r   r   r   r   r   Úseek:   s    zUnseekableIO.seekc             C   s
   t j‚d S )N)r"   r#   )r   r   r   r   Útell=   s    zUnseekableIO.tellN)Ú__name__Ú
__module__Ú__qualname__r    r!   r$   r%   r   r   r   r   r   3   s   r   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚExtensionSaverc             C   sB   || _ |tjkr8tj| | _t | jd | jd |¡ nd | _d S )Nr   r   )r   ÚcopyregÚ_inverted_registryÚpairÚremove_extension)r   r   r   r   r   Ú__init__N   s
    
zExtensionSaver.__init__c             C   sX   | j }tj |¡}|d k	r0t |d |d |¡ | j}|d k	rTt |d |d |¡ d S )Nr   r   )r   r*   r+   Úgetr-   r,   Úadd_extension)r   r   Zcurpairr,   r   r   r   ÚrestoreW   s    zExtensionSaver.restoreN)r&   r'   r(   r.   r1   r   r   r   r   r)   K   s   	r)   c               @   s   e Zd Zdd„ ZdS )ÚCc             C   s   | j |j kS )N)Ú__dict__)r   Úotherr   r   r   Ú__eq__a   s    zC.__eq__N)r&   r'   r(   r5   r   r   r   r   r2   `   s   r2   c               @   s   e Zd Zdd„ ZdS )ÚDc             C   s   d S )Nr   )r   Úargr   r   r   r.   e   s    z
D.__init__N)r&   r'   r(   r.   r   r   r   r   r6   d   s   r6   c               @   s   e Zd Zdd„ ZdS )ÚEc             C   s   dS )Nr   r   )r   r   r   r   Ú__getinitargs__i   s    zE.__getinitargs__N)r&   r'   r(   r9   r   r   r   r   r8   h   s   r8   c               @   s   e Zd ZdS )ÚHN)r&   r'   r(   r   r   r   r   r:   l   s   r:   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚKc             C   s
   || _ d S )N)Úvalue)r   r<   r   r   r   r.   q   s    z
K.__init__c             C   s   t | jffS )N)r;   r<   )r   r   r   r   Ú
__reduce__t   s    zK.__reduce__N)r&   r'   r(   r.   r=   r   r   r   r   r;   p   s   r;   Ú__main__c               @   s   e Zd Zdd„ ZdS )Úmyintc             C   s   t |ƒ| _ d S )N)Ústr)r   Úxr   r   r   r.   …   s    zmyint.__init__N)r&   r'   r(   r.   r   r   r   r   r?   „   s   r?   c               @   s   e Zd Zdd„ Zdd„ ZdS )Úinitargc             C   s   || _ || _d S )N)ÚaÚb)r   rC   rD   r   r   r   r.   Š   s    zinitarg.__init__c             C   s   | j | jfS )N)rC   rD   )r   r   r   r   r9   Ž   s    zinitarg.__getinitargs__N)r&   r'   r(   r.   r9   r   r   r   r   rB   ˆ   s   rB   c               @   s   e Zd ZdS )Ú	metaclassN)r&   r'   r(   r   r   r   r   rE   ‘   s   rE   c               @   s   e Zd ZdS )Úuse_metaclassN)r&   r'   r(   r   r   r   r   rF   ”   s   rF   )rE   c               @   s   e Zd Zdd„ Zdd„ ZdS )Úpickling_metaclassc             C   s   t | ƒt |ƒko| j|jkS )N)ÚtypeÚreduce_args)r   r4   r   r   r   r5   ˜   s    zpickling_metaclass.__eq__c             C   s
   t | jfS )N)Úcreate_dynamic_classrI   )r   r   r   r   r=   œ   s    zpickling_metaclass.__reduce__N)r&   r'   r(   r5   r=   r   r   r   r   rG   —   s   rG   c             C   s   t | |tƒ ƒ}| |f|_|S )N)rG   ÚdictrI   )ÚnameÚbasesÚresultr   r   r   rJ   Ÿ   s    
rJ   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 (K KG@       c__builtin__
complex
q(G@      G        tqRqKJÿÿÿÿKÿJÿÿÿJ ÿÿÿMÿÿJ ÿÿJ  ÿÿJÿÿÿJ  €J   €(X   abcqhccopy_reg
_reconstructor
q(c__main__
C
qc__builtin__
object
qNtqRq	}q
(X   fooqKX   barqKubh	tqhKe.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 (K KG@       c__builtin__
complex
qG@      G        †qRqKJÿÿÿÿKÿJÿÿÿJ ÿÿÿMÿÿJ ÿÿJ  ÿÿJÿÿÿJ  €J   €(X   abcqhc__main__
C
q)q}q(X   fooqKX   barq	Kubhtq
h
Ke.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 (K KG@       cbuiltins
complex
qG@      G        †qRqKJÿÿÿÿKÿJÿÿÿJ ÿÿÿMÿÿJ ÿÿJ  ÿÿJÿÿÿJ  €J   €(X   abcqhc__main__
C
q)q}q(X   barqKX   fooq	Kubhtq
h
Ke.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³   €•¨       ]”(K KG@       Œbuiltins”Œcomplex”“”G@      G        †”R”KJÿÿÿÿKÿJÿÿÿJ ÿÿÿMÿÿJ ÿÿJ  ÿÿJÿÿÿJ  €J   €(Œabc”hŒ__main__”ŒC”“”)”}”(Œbar”KŒfoo”Kubh
t”hKe.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(KKe…qRq.s%   €c__builtin__
xrange
q K KK‡qRq.sÍ   €cCookie
SimpleCookie
q )qUkeyqcCookie
Morsel
q)q(UcommentqU qUdomainqhUsecureqhUexpiresq	hUmax-ageq
hUversionqhUpathqhUhttponlyqhu}q(Ucoded_valueqUvalueqhhhhubs}qb.s"   €c__builtin__
set
q ]qKa…qRq.s   €cexceptions
?
q )Rq.sI   €cexceptions
UnicodeEncodeError
q (UasciiqX   fooqK KUbadqtqRq.c              C   s   t ƒ } d| _d| _ddddg}d}d}d}| dd	|| | d || | d || | d g¡ d
d
| | f}| |¡ | |¡ | d¡ |S )Nr   é   r   g       @y      @        éÿ   iÿÿ  iÿÿÿéÿÿÿÿÚabcé   )r2   ÚfooÚbarÚextendÚappend)ÚcrA   Zuint1maxZuint2maxZint4maxÚyr   r   r   Úcreate_dataƒ  s     


rZ   c               @   sl  e Zd Zeƒ ZdRdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zed$d%„ ƒZed&d'„ ƒZd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zed0d1„ ƒZed2d3„ ƒZd4d5„ Zd6d7„ Z d8d9„ Z!d:d;„ Z"d<d=„ Z#ed>d?„ ƒZ$d@dA„ Z%dBdC„ Z&dDdE„ Z'dFdG„ Z(dHdI„ Z)dJdK„ Z*dLdM„ Z+dNdO„ Z,e-dPdQ„ ƒZ.dS )SÚAbstractUnpickleTestsNc             C   sÜ   |d krd  ||¡}| j|||d | jt|ƒt|ƒ|d t|dƒrn| j|j|j|d | j|j|j|d t|dƒrØ| j|j	|j	|d xJ|j	D ]@}| jt||ƒt||ƒ|d | jt
||d ƒt
||d ƒ|d q”W d S )Nz{!r} is not a copy of {!r})Úmsgr3   Ú	__slots__)ÚformatÚassertEqualÚassertIsrH   ÚhasattrZassertDictEqualr3   ZassertIsNotZassertListEqualr]   Úgetattr)r   ÚobjZobjcopyr\   Zslotr   r   r   Úassert_is_copy  s    

z$AbstractUnpickleTests.assert_is_copyc             C   s†   | j |dp |  |¡Z y|  |¡ W nD tk
rl } z&tjdkrZtd||jj|f ƒ ‚ W d d }~X Y nX W d Q R X W d Q R X d S )N)Údatar   z%-32r - %s: %s)	ÚsubTestÚassertRaisesÚloadsÚBaseExceptionr   ÚverboseÚprintÚ	__class__r&   )r   Úerrorsre   Úexcr   r   r   Úcheck_unpickling_error¯  s    
z,AbstractUnpickleTests.check_unpickling_errorc             C   s   |   | j|  t¡¡ d S )N)rd   Ú	_testdatarh   ÚDATA0)r   r   r   r   Útest_load_from_data0º  s    z*AbstractUnpickleTests.test_load_from_data0c             C   s   |   | j|  t¡¡ d S )N)rd   rp   rh   ÚDATA1)r   r   r   r   Útest_load_from_data1½  s    z*AbstractUnpickleTests.test_load_from_data1c             C   s   |   | j|  t¡¡ d S )N)rd   rp   rh   ÚDATA2)r   r   r   r   Útest_load_from_data2À  s    z*AbstractUnpickleTests.test_load_from_data2c             C   s   |   | j|  t¡¡ d S )N)rd   rp   rh   ÚDATA3)r   r   r   r   Útest_load_from_data3Ã  s    z*AbstractUnpickleTests.test_load_from_data3c             C   s   |   | j|  t¡¡ d S )N)rd   rp   rh   ÚDATA4)r   r   r   r   Útest_load_from_data4Æ  s    z*AbstractUnpickleTests.test_load_from_data4c             C   sš   x”t dftdftdfgD ]z\}}|j d¡}d d|¡}|  ||Ž |  |¡¡ d d|¡}|  ||Ž |  |¡¡ d d|¡}|  ||Ž |  |¡¡ qW d S )Nr   )rA   Úasciis   (i__main__
X
p0
(dp1
b.ó   Xs   (c__main__
X
q oq}qb.s   €(c__main__
X
q oq}qb.)r2   r6   r8   r&   ÚencodeÚreplacerd   rh   )r   ÚXr   ZxnameZpickle0Zpickle1Zpickle2r   r   r   Útest_load_classic_instanceÉ  s     z0AbstractUnpickleTests.test_load_classic_instancec             C   sV   d}dt |ƒ d¡ d }|  |¡}|  ||¡ dt |ƒ d¡ d }|  t|¡ d S )Nl   ÿÿÿÿ ó   Ir{   s   
.s   JUNK
.)r@   r}   rh   rd   ro   Ú
ValueError)r   Zmaxint64re   Úgotr   r   r   Útest_maxint64  s    
z#AbstractUnpickleTests.test_maxint64c             C   s\  |   t¡}|  |tddgƒ¡ |   t¡}|  t|ƒttdƒƒ¡ |  t|ƒttdƒƒ¡ |   t¡}|  t|ƒt	¡ |  t| 
¡ ƒdg¡ |  |d jd¡ x:tD ]2}t d|j d¡¡}|   |¡}|  t|ƒ|¡ q W |   t dd	¡¡}|  t|ƒt¡ |   t¡}|  t|ƒt¡ |  |jd
¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ d S )Nr   rO   r   rS   Úkeyr<   ó   ?r{   s   StandardErrorrT   Zbad)rh   ÚDATA_SETr_   ÚsetÚDATA_XRANGErH   ÚrangeÚlistÚDATA_COOKIEr   Úkeysr<   Úpython2_exceptions_without_argsÚexception_pickler~   r&   r}   r`   Ú	ExceptionÚ
DATA_UEERRÚUnicodeEncodeErrorÚobjectÚencodingÚstartÚendÚreason)r   Úloadedrn   re   r   r   r   Útest_unpickle_from_2x  s,    





z+AbstractUnpickleTests.test_unpickle_from_2xc             C   sF   |   | jdddd¡ |   | jdddd¡ |   | jdddd¡ d S )Ns   S'a\x00\xa0'
.Úbytes)r”   s   a  s   Ua  .s   €Ua  .)r_   rh   )r   r   r   r   Útest_load_python2_str_as_bytes*  s    


z4AbstractUnpickleTests.test_load_python2_str_as_bytesc             C   sF   |   | jdddd¡ |   | jdddd¡ |   | jdddd¡ d S )Ns	   V\u03c0
.rš   )r”   u   Ï€s   X   Ï€.s
   €X   Ï€.)r_   rh   )r   r   r   r   Ú test_load_python2_unicode_as_str5  s    


z6AbstractUnpickleTests.test_load_python2_unicode_as_strc             C   s2   |   | jtjt dd¡ d tj ddd¡ d S )Nz<Ii,  s,  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrš   )r”   )r_   rh   r   Z	BINSTRINGÚstructÚpackÚSTOP)r   r   r   r   Ú#test_load_long_python2_str_as_bytes@  s    z9AbstractUnpickleTests.test_load_long_python2_str_as_bytesc             C   s\   |   |  d¡¡ |  |  d¡d¡ |  |  d¡d¡ |  |  d¡d¡ |  |  d¡d¡ d S )Ns   N.s   ˆ.Ts   ‰.Fs   I01
.s   I00
.)ZassertIsNonerh   r`   )r   r   r   r   Útest_constantsG  s
    z$AbstractUnpickleTests.test_constantsc             C   s   | j ddd}|  |d¡ d S )Ns   €U q .zkoi8-r)r”   Ú )rh   r_   )r   Úemptyr   r   r   Útest_empty_bytestringN  s    z+AbstractUnpickleTests.test_empty_bytestringc             C   s   d}|   |  |¡d¡ d S )Ns	   €Câ‚¬ .s   â‚¬ )r_   rh   )r   Údumpedr   r   r   Útest_short_binbytesS  s    z)AbstractUnpickleTests.test_short_binbytesc             C   s   d}|   |  |¡d¡ d S )Ns   €B   â‚¬ .s   â‚¬ )r_   rh   )r   r¥   r   r   r   Útest_binbytesW  s    z#AbstractUnpickleTests.test_binbytesc             C   s   d}|   tjtf|¡ d S )Ns   €Bÿÿÿÿxyzq .)ro   r   ÚUnpicklingErrorÚOverflowError)r   r¥   r   r   r   Útest_negative_32b_binbytes[  s    z0AbstractUnpickleTests.test_negative_32b_binbytesc             C   s   d}|   tjtf|¡ d S )Ns   €Xÿÿÿÿxyzq .)ro   r   r¨   r©   )r   r¥   r   r   r   Útest_negative_32b_binunicodeb  s    z2AbstractUnpickleTests.test_negative_32b_binunicodec             C   s   d}|   |  |¡d¡ d S )Ns	   €Œâ‚¬ .u   â‚¬ )r_   rh   )r   r¥   r   r   r   Útest_short_binunicodei  s    z+AbstractUnpickleTests.test_short_binunicodec             C   s&   |   td¡ |  ddg|  d¡¡ d S )Ns   g0
p0)éd   s   ((Kdtp0
h l.)))ro   ÚKeyErrorrd   rh   )r   r   r   r   Útest_misc_getm  s    
z#AbstractUnpickleTests.test_misc_getc             C   s   d}|   |  |¡d¡ d S )Ns   €Ž       â‚¬ .s   â‚¬ )r_   rh   )r   r¥   r   r   r   Útest_binbytes8r  s    z$AbstractUnpickleTests.test_binbytes8c             C   s   d}|   |  |¡d¡ d S )Ns   €       â‚¬ .u   â‚¬ )r_   rh   )r   r¥   r   r   r   Útest_binunicode8v  s    z&AbstractUnpickleTests.test_binunicode8c             C   s   d}|   tjtf|¡ d S )Ns   €Ž      â‚¬ .)ro   r   r¨   r©   )r   r¥   r   r   r   Útest_large_32b_binbytes8z  s    z.AbstractUnpickleTests.test_large_32b_binbytes8c             C   s   d}|   tjtf|¡ d S )Ns   €      â‚¬ .)ro   r   r¨   r©   )r   r¥   r   r   r   Útest_large_32b_binunicode8€  s    z0AbstractUnpickleTests.test_large_32b_binunicode8c             C   s8   d}|   |¡}|  |g fd ¡ |  |d |d ¡ d S )Ns   ((lp100000
g100000
t.rO   r   r   )rh   r_   r`   )r   ÚpickledÚ	unpickledr   r   r   Útest_get†  s    
zAbstractUnpickleTests.test_getc             C   s8   d}|   |¡}|  |g fd ¡ |  |d |d ¡ d S )Ns   (]qÿhÿt.rO   r   r   )rh   r_   r`   )r   r´   rµ   r   r   r   Útest_bingetŒ  s    
z!AbstractUnpickleTests.test_bingetc             C   s8   d}|   |¡}|  |g fd ¡ |  |d |d ¡ d S )Ns   (]r   j   t.rO   r   r   )rh   r_   r`   )r   r´   rµ   r   r   r   Útest_long_binget’  s    
z&AbstractUnpickleTests.test_long_bingetc             C   s8   d}|   |¡}|  |g fd ¡ |  |d |d ¡ d S )Ns   ((l2t.rO   r   r   )rh   r_   r`   )r   r´   rµ   r   r   r   Útest_dup˜  s    
zAbstractUnpickleTests.test_dupc             C   s   d}|   t|¡ d S )Ns   Va
p-1
.)ro   r‚   )r   r¥   r   r   r   Útest_negative_putž  s    z'AbstractUnpickleTests.test_negative_putc             C   s   d}|   t|¡ d S )Ns   €X   arÿÿÿÿ.)ro   r‚   )r   r¥   r   r   r   Útest_negative_32b_binput£  s    z.AbstractUnpickleTests.test_negative_32b_binputc             C   s   |   td¡ d S )Ns   S'\'
.)ro   r‚   )r   r   r   r   Útest_badly_escaped_string©  s    z/AbstractUnpickleTests.test_badly_escaped_stringc             C   s>   ddddddddd	d
dddg}x|D ]}|   tj|¡ q$W d S )Ns   S'
.s   S"
.s   S' 
.s   S" 
.s   S'"
.s   S"'
.s   S' ' 
.s   S" " 
.s   S ''
.s   S ""
.s   S 
.s   S
.s   S.)ro   r   r¨   )r   Ú
badpicklesÚpr   r   r   Útest_badly_quoted_string¬  s    
z.AbstractUnpickleTests.test_badly_quoted_stringc             C   s4   ddddg}x"|D ]\}}|   |  |¡|¡ qW d S )N)s   S''
.r¢   )s   S""
.r¢   )s   S"\n"
.Ú
)s   S'\n'
.rÀ   )r_   rh   )r   Zgoodpicklesr¾   Úexpectedr   r   r   Útest_correctly_quoted_string¾  s    z2AbstractUnpickleTests.test_correctly_quoted_stringc             C   s   d}|   |  |¡d¡ d S )Ns   €•       I42
.é*   )r_   rh   )r   r´   r   r   r   Útest_frame_readlineÆ  s    z)AbstractUnpickleTests.test_frame_readlinec          	   C   s  d}|   |¡}|  t|ƒt¡ |  |tddƒ¡ |  t|ƒddddddg¡ d	}|  |   |¡tj¡ d
}|  |   |¡tj	¡ xBdD ]:}d| d }|   |¡}|  t|ƒt
¡ |  t|ƒd¡ q‚W xJdD ]B}d| d }|   |¡}|  t|ƒtj¡ |  |t ddi¡¡ qÆW d S )Ns   €c__builtin__
xrange
KKK‡R.r   é   rO   é   é   rS   é   s   €c__builtin__
reduce
.s   €cwhichdb
whichdb
.)s	   Exceptions   StandardErrors   €cexceptions
s	   
Uugh…R.Zugh)s   UserDicts   IterableUserDicts   €(cUserDict
s   
o}Udata}KKssb.)rh   r`   rH   rŠ   r_   r‹   Ú	functoolsÚreduceÚdbmÚwhichdbr   r@   ÚcollectionsÚUserDict)r   r´   rµ   rL   r   r   r   Útest_compat_unpickleÎ  s(    




z*AbstractUnpickleTests.test_compat_unpicklec          ,   C   s|   ddddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g,}x|D ]}|   | j|¡ qbW d S )-Nó   .ó   0ó   1ó   2s   (2ó   Rs   )Ró   as   Naó   bs   Nbó   dó   es   (es   ibuiltins
list
ó   ló   os   (os   p1
s   q s   r    ó   ss   Nss   NNsó   tó   us   (us   }(Nuó   s   )ó   …ó   †s   N†ó   ‡s   N‡s   NN‡ó   s   (ó   ‘ó   ’s   )}’ó   “s   Vlist
“ó   ”)ro   Úbad_stack_errors)r   r½   r¾   r   r   r   Útest_bad_stacké  s\    
z$AbstractUnpickleTests.test_bad_stackc             C   s`   ddddddddd	d
ddddddddddddddddddddg}x|D ]}|   | j|¡ qFW d S )Ns   N(.s   N(2s   cbuiltins
list
)(Rs   cbuiltins
list
()Rs   ]N(as   cbuiltins
ValueError
)R}(bs   cbuiltins
ValueError
)R(}bs   (Nds   N(p1
s   N(q s   N(r    s   }NN(ss   }N(Nss   }(NNss   }((us   cbuiltins
list
)(s   cbuiltins
list
()s   N(…s   NN(†s   N(N†s   NNN(‡s   NN(N‡s   N(NN‡s   ]((s   cbuiltins
list
)}(’s   cbuiltins
list
)(}’s   cbuiltins
list
()}’s   Vbuiltins
(Vlist
“s   Vbuiltins
Vlist
(“s   N(”)ro   rç   )r   r½   r¾   r   r   r   Útest_bad_mark  s@    
z#AbstractUnpickleTests.test_bad_markc          Q   C   sÞ   |   td¡ |   td¡ ddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSgQ}x|D ]}|   | j|¡ qÄW d S )TNó    ó   Nó   Bs   B  s   B   s   B   abó   Cs   Cs   Cabó   Fs   F0.0s   F0.00ó   Gs   G       r   s   I0ó   Js   J   ó   Kó   Ls   L0s   L10s   L0Ls   L10Ló   Ms   M ó   Ss   S'abc'ó   Ts   T  s   T   s   T   abó   Us   Us   Uabó   Vs   Vabcr|   s   X  s   X   s   X   abs   (cs
   (cbuiltinss   (cbuiltins
s   (cbuiltins
lists   Ngs   Ng0s   (is
   (ibuiltinss   (ibuiltins
s   (ibuiltins
lists   Nhs   Njs   Nj   s   Nps   Np0s   Nqs   Nrs   Nr   ó   €ó   ‚ó   ƒs   „ó   „s   „  ó   Šó   ‹s   ‹   ó   Œs   Œs   Œabó   s         s	          s          abó   Žs   Ž      s	   Ž       s   Ž       abó   •s   •      s	   •       s
   •       N)ro   ÚEOFErrorZtruncated_errors)r   r½   r¾   r   r   r   Útest_truncated_dataB  sª    
z)AbstractUnpickleTests.test_truncated_datac       	   	      s^  t dƒ}t dƒ}t t¡ |  tjt¡ tj 	dt¡ |  tjj
t¡ ttj td¡dƒ}| | d¡¡ W d Q R X ttj td¡dƒ}| | d¡¡ W d Q R X |  td¡ |  td	¡ dd l}d
‰g ‰t d¡‰ ‡ ‡‡fdd„}tj|d}tj|d}| ¡  | ¡  ˆ  ¡  |j ¡  | ¡  | ¡  ddlm} |  dd„ ˆD ƒ|gd ¡ d S )NzI
        import threading
        barrier = threading.Barrier(2)
        zs
        import locker
        locker.barrier.wait()
        class ToBeUnpickled(object):
            pass
        r   z	locker.pyÚwbzutf-8zlocking_import.pyÚlockerÚlocking_imports'   €clocking_import
ToBeUnpickled
q )q.rÆ   c                  s   ˆ   ¡  ˆ t ˆ¡¡ d S )N)ÚwaitrW   r   rh   r   )ÚbarrierÚpickle_bytesÚresultsr   r   ÚtÂ  s    z:AbstractUnpickleTests.test_unpickle_module_race.<locals>.t)Útarget)ÚToBeUnpickledc             S   s   g | ]}t |ƒ‘qS r   )rH   )Ú.0rA   r   r   r   ú
<listcomp>Ö  s    zCAbstractUnpickleTests.test_unpickle_module_race.<locals>.<listcomp>rO   )r   ÚosÚmkdirr   Z
addCleanupÚshutilZrmtreeÚsysÚpathÚinsertÚremoveÚopenÚjoinÚwriter}   r   r  Ú	threadingZBarrierZThreadr•   r  r  r  r  r_   )	r   Zlocker_moduleZlocking_import_moduleÚfr  r  Zt1Út2r  r   )r  r	  r
  r   Útest_unpickle_module_race  s>    


z/AbstractUnpickleTests.test_unpickle_module_race)N)/r&   r'   r(   rZ   rp   rd   ro   rr   rt   rv   rx   rz   r€   r„   r™   r›   rœ   r    r¡   r¤   r¦   r§   Úrequires_32brª   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[   ˜  sR   
9
2'[r[   c               @   sì  e Zd ZdZejZdd„ ZejZdd„ Zdd„ Z	dd	„ Z
d
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Z d6d7„ Z!d8d9„ Z"d:d;„ Z#d<d=„ Z$d>d?„ Z%e&d@dAdBƒdCdD„ ƒZ'dEdF„ Z(dGdH„ Z)dIdJ„ Z*dKdL„ Z+dMdN„ Z,dOdP„ Z-dQdR„ Z.dSdT„ Z/dUdV„ Z0dWdX„ Z1dYdZ„ Z2d[d\„ Z3d]d^„ Z4d_d`„ Z5dadb„ Z6dcdd„ Z7dedf„ Z8dgdh„ Z9didj„ Z:dkdl„ Z;dmdn„ Z<dodp„ Z=dqdr„ Z>dsdt„ Z?dudv„ Z@dwdx„ ZAdydz„ ZBd{d|„ ZCd}d~„ ZDdd€„ ZEdd‚„ ZFdƒd„„ ZGd…d†„ ZHd‡dˆ„ ZIeJd‰dŠ„ ƒZKd‹dŒ„ ZLddŽ„ ZMdd„ ZNd‘d’„ ZOd“d”„ ZPd•d–„ ZQd—d˜„ ZRd™dš„ ZSd›dœ„ ZTdZUdžZVdŸd „ ZWd¡d¢„ ZXd£d¤„ ZYd¥d¦„ ZZd§d¨„ Z[d©dª„ Z\d«d¬„ Z]d­d®„ Z^d¯d°„ Z_d±d²„ Z`d³d´„ ZadµS )¶ÚAbstractPickleTestsFc             C   s   d S )Nr   )r   r   r   r   ÚsetUpâ  s    zAbstractPickleTests.setUpc             C   sŽ   xˆt D ]€}tdƒ}|  ||¡}|  |¡}|  ||¡ d}|  ||¡}|  |¡}|  ||¡ td|ƒ}|  ||¡}|  |¡}|  ||¡ qW d S )NrÇ   )r   r   r   )Ú	protocolsr?   Údumpsrh   rd   rB   )r   ÚprotorA   ÚsrY   r   r   r   Ú	test_miscç  s    




zAbstractPickleTests.test_miscc             C   s:   | j }x.tD ]&}|  ||¡}|  |¡}|  ||¡ qW d S )N)rp   r!  r"  rh   rd   )r   rÁ   r#  r$  rƒ   r   r   r   Útest_roundtrip_equalityû  s
    

z+AbstractPickleTests.test_roundtrip_equalityc             C   sn   ddl m} ddlm} xPdtfdtffD ]<\}}|  | j|¡}|ƒ }|||d | ¡ }|  	||¡ q*W d S )Nr   )ÚStringIO)Údisr   )Úout)
r"   r'  r   r(  Ú	DATA0_DISÚ	DATA1_DISr"  rp   Úgetvaluer_   )r   r'  r(  r#  rÁ   r$  Zfilelikerƒ   r   r   r   Údont_test_disassembly  s    z)AbstractPickleTests.dont_test_disassemblyc             C   sb   g }|  |¡ xNtD ]F}|  ||¡}|  |¡}|  |t¡ |  t|ƒd¡ |  |d |¡ qW d S )Nr   r   )	rW   r!  r"  rh   ÚassertIsInstancer‹   r_   Úlenr`   )r   Úlr#  r$  rA   r   r   r   Útest_recursive_list  s    


z'AbstractPickleTests.test_recursive_listc             C   s   g f}|d   |¡ xvtD ]n}|  ||¡}|  |¡}|  |t¡ |  t|ƒd¡ |  |d t¡ |  t|d ƒd¡ |  	|d d |¡ qW d S )Nr   r   )
rW   r!  r"  rh   r.  Útupler_   r/  r‹   r`   )r   r  r#  r$  rA   r   r   r   Útest_recursive_tuple_and_list  s    

z1AbstractPickleTests.test_recursive_tuple_and_listc             C   sf   i }||d< xTt D ]L}|  ||¡}|  |¡}|  |t¡ |  t| ¡ ƒdg¡ |  |d |¡ qW d S )Nr   )	r!  r"  rh   r.  rK   r_   r‹   r   r`   )r   Údr#  r$  rA   r   r   r   Útest_recursive_dict)  s    

z'AbstractPickleTests.test_recursive_dictc             C   sŽ   i }t |ƒ}d||< xttD ]l}|  ||¡}|  |¡}|  |t¡ |  t| ¡ ƒd¡ |  t	| ¡ ƒd t ¡ |  
t	| ¡ ƒd j|¡ qW d S )Nr   r   )r;   r!  r"  rh   r.  rK   r_   r/  r   r‹   r`   r<   )r   r4  Úkr#  r$  rA   r   r   r   Útest_recursive_dict_key3  s    

z+AbstractPickleTests.test_recursive_dict_keyc             C   s’   t ƒ }t|ƒ}| |¡ xttdtjd ƒD ]`}|  ||¡}|  |¡}|  |t ¡ |  	t
|ƒd¡ |  t|ƒd t¡ |  t|ƒd j|¡ q*W d S )NrÇ   r   r   )rˆ   r;   ÚaddrŠ   r   ÚHIGHEST_PROTOCOLr"  rh   r.  r_   r/  r‹   r`   r<   )r   rY   r6  r#  r$  rA   r   r   r   Útest_recursive_set?  s    

z&AbstractPickleTests.test_recursive_setc             C   sp   t ƒ }| |¡ xZtdtjd ƒD ]F}|  ||¡}|  |¡}|  |t ¡ |  t	|ƒd¡ |  
|d |¡ q"W d S )NrO   r   r   )ÚMyListrW   rŠ   r   r9  r"  rh   r.  r_   r/  r`   )r   rY   r#  r$  rA   r   r   r   Útest_recursive_list_subclassK  s    

z0AbstractPickleTests.test_recursive_list_subclassc             C   st   t ƒ }||d< x`tdtjd ƒD ]L}|  ||¡}|  |¡}|  |t ¡ |  t| 	¡ ƒdg¡ |  
|d |¡ q W d S )Nr   rO   )ÚMyDictrŠ   r   r9  r"  rh   r.  r_   r‹   r   r`   )r   r4  r#  r$  rA   r   r   r   Útest_recursive_dict_subclassU  s    
z0AbstractPickleTests.test_recursive_dict_subclassc             C   s    t ƒ }t|ƒ}d||< x„tdtjd ƒD ]p}|  ||¡}|  |¡}|  |t ¡ |  t	t
| ¡ ƒƒd¡ |  t
| ¡ ƒd t¡ |  t
| ¡ ƒd j|¡ q(W d S )Nr   rO   r   )r=  r;   rŠ   r   r9  r"  rh   r.  r_   r/  r‹   r   r`   r<   )r   r4  r6  r#  r$  rA   r   r   r   Ú test_recursive_dict_subclass_key_  s    
z4AbstractPickleTests.test_recursive_dict_subclass_keyc             C   sb   t ƒ }||_xPtD ]H}|  ||¡}|  |¡}|  |t ¡ |  t|ƒt|ƒ¡ |  |j|¡ qW d S )N)	r2   Úattrr!  r"  rh   r.  r_   Údirr`   )r   Úir#  r$  rA   r   r   r   Útest_recursive_instk  s    

z'AbstractPickleTests.test_recursive_instc             C   s²   g }d|i}t ƒ }||_| |¡ xŠtD ]‚}|  ||¡}|  |¡}|  |t¡ |  t	|ƒd¡ |  t
|d ƒt
|ƒ¡ |  t|d j ¡ ƒdg¡ |  |d jd |k¡ q(W d S )Nr   r   )r2   r@  rW   r!  r"  rh   r.  r‹   r_   r/  rA  r   Ú
assertTrue)r   r0  r4  rB  r#  r$  rA   r   r   r   Útest_recursive_multiu  s    


z(AbstractPickleTests.test_recursive_multic             C   sˆ   t ƒ }||gƒ}||_xltD ]d}|  ||¡}|  |¡}|  |t|ƒ¡ |  t|ƒd¡ |  t	|ƒd t ¡ |  
t	|ƒd j|¡ qW d S )Nr   r   )r:   r@  r!  r"  rh   r.  rH   r_   r/  r‹   r`   )r   ÚfactoryÚhrY   r#  r$  rA   r   r   r   Ú#check_recursive_collection_and_inst„  s    


z7AbstractPickleTests.check_recursive_collection_and_instc             C   s   |   t¡ d S )N)rH  r‹   )r   r   r   r   Útest_recursive_list_and_inst  s    z0AbstractPickleTests.test_recursive_list_and_instc             C   s   |   t¡ d S )N)rH  r2  )r   r   r   r   Útest_recursive_tuple_and_inst“  s    z1AbstractPickleTests.test_recursive_tuple_and_instc             C   s   |   tj¡ d S )N)rH  rK   Úfromkeys)r   r   r   r   Útest_recursive_dict_and_inst–  s    z0AbstractPickleTests.test_recursive_dict_and_instc             C   s   |   t¡ d S )N)rH  rˆ   )r   r   r   r   Útest_recursive_set_and_inst™  s    z/AbstractPickleTests.test_recursive_set_and_instc             C   s   |   t¡ d S )N)rH  Ú	frozenset)r   r   r   r   Ú!test_recursive_frozenset_and_instœ  s    z5AbstractPickleTests.test_recursive_frozenset_and_instc             C   s   |   t¡ d S )N)rH  r;  )r   r   r   r   Ú%test_recursive_list_subclass_and_instŸ  s    z9AbstractPickleTests.test_recursive_list_subclass_and_instc             C   s   |   t¡ d S )N)rH  ÚMyTuple)r   r   r   r   Ú&test_recursive_tuple_subclass_and_inst¢  s    z:AbstractPickleTests.test_recursive_tuple_subclass_and_instc             C   s   |   tj¡ d S )N)rH  r=  rK  )r   r   r   r   Ú%test_recursive_dict_subclass_and_inst¥  s    z9AbstractPickleTests.test_recursive_dict_subclass_and_instc             C   s   |   t¡ d S )N)rH  ÚMySet)r   r   r   r   Ú$test_recursive_set_subclass_and_inst¨  s    z8AbstractPickleTests.test_recursive_set_subclass_and_instc             C   s   |   t¡ d S )N)rH  ÚMyFrozenSet)r   r   r   r   Ú*test_recursive_frozenset_subclass_and_inst«  s    z>AbstractPickleTests.test_recursive_frozenset_subclass_and_instc             C   sT   dddddddg}x<t D ]4}x.|D ]&}|  ||¡}|  |¡}|  ||¡ q"W qW d S )Nr¢   z<\u>u   <\áˆ´>z<
>z<\>u   <\ð’…>u   <í²€>)r!  r"  rh   rd   )r   Zendcasesr#  Úur¾   Zu2r   r   r   Útest_unicode®  s    


z AbstractPickleTests.test_unicodec             C   s8   d}x.t D ]&}|  ||¡}|  |¡}|  ||¡ q
W d S )Nu   ð’…)r!  r"  rh   rd   )r   r  r#  r¾   r  r   r   r   Útest_unicode_high_plane¹  s
    

z+AbstractPickleTests.test_unicode_high_planec             C   s²   x¬t D ]¤}x*dD ]"}|  ||¡}|  ||  |¡¡ qW x8dd„ tdƒD ƒD ]"}|  ||¡}|  ||  |¡¡ qJW x8dd„ tdƒD ƒD ]"}|  ||¡}|  ||  |¡¡ q„W qW d S )N)rê   s   xyzs,  xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzc             S   s   g | ]}t |gƒ‘qS r   )rš   )r  rB  r   r   r   r  Å  s    z2AbstractPickleTests.test_bytes.<locals>.<listcomp>é   c             S   s   g | ]}t ||gƒ‘qS r   )rš   )r  rB  r   r   r   r  È  s    )r!  r"  rd   rh   rŠ   )r   r#  r$  r¾   r   r   r   Ú
test_bytesÀ  s    

zAbstractPickleTests.test_bytesc             C   s`   xZt D ]R}tj}xF|rVx4| |fD ]&}|  ||¡}|  |¡}|  ||¡ q"W |d? }qW qW d S )Nr   )r!  r  Úmaxsizer"  rh   rd   )r   r#  r   rÁ   r$  Zn2r   r   r   Ú	test_intsÌ  s    

zAbstractPickleTests.test_intsc       	      C   sÖ   xtt D ]l}xfdD ]^}d|> }xP|d ||d fD ]:}x4|| fD ]&}|  ||¡}|  |¡}|  ||¡ q@W q0W qW qW tddƒ}||d> 7 }xD|| fD ]6}|  |d¡}|  |¡}|  t|ƒt¡ |  ||¡ q˜W d S )N)r   é   ið  iø  i   i  r   Zdeadbeeffeedfaceé   i@B rO   )r!  r"  rh   rd   Úintr`   rH   r_   )	r   r#  ZnbitsZnbaseZnposr   r   rƒ   r¾   r   r   r   Ú	test_longÖ  s    




zAbstractPickleTests.test_longc             C   sn   ddddddddd	d
dg}|dd„ |D ƒ }x<t D ]4}x.|D ]&}|  ||¡}|  |¡}|  ||¡ q<W q2W d S )Ng        g       g+æp‹h  gà®Z¤î*) g_DÅø…9gš™™™™™¹?g      à?g…ëQ¸	@g‘mÎ"wp@gêWôTáßDgêŒ 9Y>)Fc             S   s   g | ]
}| ‘qS r   r   )r  rA   r   r   r   r  ð  s    z2AbstractPickleTests.test_float.<locals>.<listcomp>)r!  r"  rh   rd   )r   Ztest_valuesr#  r<   r   rƒ   r   r   r   Ú
test_floatí  s    


zAbstractPickleTests.test_floatÚLC_ALLÚde_DEÚfr_FRc             C   s    |   |  dd¡dd… d¡ d S )Ng333333ó?r   rÆ   s   F1.)r_   r"  )r   r   r   r   Útest_float_format÷  s    z%AbstractPickleTests.test_float_formatc             C   s:   x4t D ],}tƒ }|  ||¡}|  |¡}|  |t¡ qW d S )N)r!  ÚAAAr"  rh   r_   ÚREDUCE_A)r   r#  Úinstr¥   r˜   r   r   r   Útest_reduceü  s
    

zAbstractPickleTests.test_reducec             C   s>   x8t D ]0}tddƒ}|  ||¡}|  |¡}|  ||¡ qW d S )Nr   rO   )r!  rB   r"  rh   rd   )r   r#  rj  r¥   r˜   r   r   r   Útest_getinitargs  s
    


z$AbstractPickleTests.test_getinitargsc             C   s>   t ƒ }x2tD ]*}|  ||¡}|  |¡}|  |j|j¡ qW d S )N)rF   r!  r"  rh   r_   rl   )r   rC   r#  r$  rD   r   r   r   Útest_metaclass
  s
    

z"AbstractPickleTests.test_metaclassc             C   sb   t dtfƒ}t ttj¡ xBtD ]:}|  ||¡}|  |¡}|  	||¡ |  
t|ƒt|ƒ¡ q W d S )NZmy_dynamic_class)rJ   r“   r*   r   rG   r=   r!  r"  rh   r_   r`   rH   )r   rC   r#  r$  rD   r   r   r   Útest_dynamic_class  s    

z&AbstractPickleTests.test_dynamic_classc             C   s¼   dd l }dd l}| ¡ }xžtD ]–}|  ||¡}|  |¡}|  ||¡ t|dƒr|| |j	¡}|  ||¡}|  |¡}|  ||¡ t|dƒr| 
|j	¡}|  ||¡}|  |¡}|  ||¡ qW d S )Nr   ÚstatÚstatvfs)Útimer  Z	localtimer!  r"  rh   rd   ra   ro  Úcurdirrp  )r   rq  r  r  r#  r$  rX  r   r   r   Útest_structseq  s"    





z"AbstractPickleTests.test_structseqc             C   s4   x.t D ]&}|  d|¡}|  |¡}|  d|¡ qW d S )N.)r!  r"  rh   r`   )r   r#  r$  rX  r   r   r   Útest_ellipsis.  s    

z!AbstractPickleTests.test_ellipsisc             C   s4   x.t D ]&}|  t|¡}|  |¡}|  t|¡ qW d S )N)r!  r"  ÚNotImplementedrh   r`   )r   r#  r$  rX  r   r   r   Útest_notimplemented4  s    

z'AbstractPickleTests.test_notimplementedc             C   sT   d dt g}xD|D ]<}x6tD ].}|  t|ƒ|¡}|  |¡}|  t|ƒ|¡ qW qW d S )N.)ru  r!  r"  rH   rh   r`   )r   Z
singletonsZ	singletonr#  r$  rX  r   r   r   Útest_singleton_types:  s    



z(AbstractPickleTests.test_singleton_typesc          
   C   sÔ   xVt D ]N}|  d |¡}|dkr@tjt|gƒ }|  | |¡¡ q|  ttj|ƒd¡ qW t d d }tj	tj
 }tjt|gƒ | }y|  |¡ W n2 tk
rÄ } z|  dt|ƒ¡ W d d }~X Y nX |  d¡ d S )NrO   r   rQ   r   zunsupported pickle protocolz0expected bad protocol number to raise ValueError)r!  r"  r   ÚPROTOrš   rD  Ú
startswithr_   r   ÚNONErŸ   rh   r‚   ÚassertInr@   Zfail)r   r#  r´   Zproto_headerZoobZ
build_noneZ	badpickleÚerrr   r   r   Ú
test_protoE  s    
"zAbstractPickleTests.test_protoc             C   sP   d}xFt D ]>}|  ||¡}|  |¡}|  ||¡ |  ttj|ƒ|dk¡ q
W d S )Nl   èUJ^w,3ƒ|	 rO   )r!  r"  rh   rd   r_   r   r   ZLONG1)r   rA   r#  r$  rY   r   r   r   Ú
test_long1X  s    

zAbstractPickleTests.test_long1c             C   sT   dd> }xFt D ]>}|  ||¡}|  |¡}|  ||¡ |  ttj|ƒ|dk¡ qW d S )Nl   èUJ^w,3ƒ|	 i   rO   )r!  r"  rh   rd   r_   r   r   ZLONG4)r   rA   r#  r$  rY   r   r   r   Ú
test_long4`  s    

zAbstractPickleTests.test_long4c             C   sÜ   t jt jt jt jt jt jt jt jt jt jt jt jt jt jt jt jt jt jt jt jdœ}d}d}d}d}d}xltD ]d}x^|||||fD ]L}|  ||¡}	|  |	¡}
|  	||
¡ |t
|dƒt|ƒf }|  t||	ƒ¡ q„W qpW d S )N))r   r   )r   r   )r   rO   )r   rÆ   )r   rÇ   )r   r   )r   r   )r   rO   )r   rÆ   )r   rÇ   )rO   r   )rO   r   )rO   rO   )rO   rÆ   )rO   rÇ   )rÆ   r   )rÆ   r   )rÆ   rO   )rÆ   rÆ   )rÆ   rÇ   r   )r   )r   rO   )r   rO   rÆ   )r   rO   rÆ   rÇ   rÆ   )r   ZTUPLEZEMPTY_TUPLEZTUPLE1ZTUPLE2ZTUPLE3r!  r"  rh   rd   Úminr/  rD  r   )r   Úexpected_opcoderC   rD   rX   r4  Úer#  rA   r$  rY   rÁ   r   r   r   Útest_short_tuplesh  s@    


z%AbstractPickleTests.test_short_tuplesc             C   s¦   t jt jt jt jt jt jt jt jt jt jt jt jdœ}xjtD ]b}x\dD ]T}|  ||¡}|  |¡}|  ||k||||f¡ |t	|dƒ|f }|  t
||ƒ¡ qFW q<W d S )N))r   N)r   N)rO   N)rÆ   N)r   T)r   T)rO   T)rÆ   T)r   F)r   F)rO   F)rÆ   F)NFTrÆ   )r   rz  ZINTZNEWTRUEZNEWFALSEr!  r"  rh   rD  r€  r   )r   r  r#  rA   r$  rY   rÁ   r   r   r   Útest_singletons  s&    



z#AbstractPickleTests.test_singletonsc             C   sN   t dddgƒ}d|_d|_x.tD ]&}|  ||¡}|  |¡}|  ||¡ q W d S )Nr   rO   rÆ   rÃ   Úhello)rQ  rT   rU   r!  r"  rh   rd   )r   rA   r#  r$  rY   r   r   r   Útest_newobj_tuple¨  s    

z%AbstractPickleTests.test_newobj_tuplec             C   sN   t dddgƒ}d|_d|_x.tD ]&}|  ||¡}|  |¡}|  ||¡ q W d S )Nr   rO   rÆ   rÃ   r…  )r;  rT   rU   r!  r"  rh   rd   )r   rA   r#  r$  rY   r   r   r   Útest_newobj_list±  s    

z$AbstractPickleTests.test_newobj_listc          	   C   s”   xŽt D ]†}x€tD ]x}|j}||jƒ}d|_|  ||¡}|  |¡}|||||t|ƒf}|  ||¡ |  	||ƒ||ƒ|¡ |  	|j
|j
|¡ qW qW d S )NrÃ   )r!  Ú	myclassesÚ__base__ÚsamplerT   r"  rh   rH   rd   r_   r3   )r   r#  r2   ÚBrA   r$  rY   Údetailr   r   r   Útest_newobj_genericº  s    



z'AbstractPickleTests.test_newobj_genericc          	   C   sÎ   t d d … }xttfD ]}| |¡ qW x tD ]˜}x’|D ]Š}|j}||jƒ}d|_t 	|¡}|  
||¡}|  |¡}	|  t|	ƒt|ƒ¡ |||||	t|	ƒf}
|  ||ƒ||	ƒ|
¡ |  |j|	j|
¡ q8W q.W d S )NrÃ   )rˆ  ÚMyIntrQ  r  r!  r‰  rŠ  rT   ÚweakrefÚproxyr"  rh   r_   rH   r3   )r   ÚclassesrX   r#  r2   r‹  rA   r¾   r$  rY   rŒ  r   r   r   Útest_newobj_proxiesÇ  s    




z'AbstractPickleTests.test_newobj_proxiesc             C   sD   t }t  t ¡}|  |d¡}zda |  ttjf| j|¡ W d |a X d S )NrÇ   rÃ   )ÚSimpleNewObjÚ__new__r"  rg   Ú	TypeErrorr   r¨   rh   )r   ZsaveÚorD   r   r   r   Útest_newobj_not_classÚ  s    
z)AbstractPickleTests.test_newobj_not_classc             C   sì   t |ƒ}zÔt td|¡ tdddgƒ}d|_d|_|  |d¡}|  t 	d¡|¡ |  d|¡ |  
t||ƒ¡ |  |¡}|  ||¡ |  |d¡}|  t 	d¡|¡ |  d|¡ |  t||ƒd	t|ƒ¡ |  |¡}|  ||¡ W d | ¡  X d S )
Nr;  r   rO   rÆ   rÃ   r…  zutf-8s   MyListT)r)   r*   r0   r&   r;  rT   rU   r"  r{  r}   ÚassertFalser   rh   rd   ZassertNotInr_   Úreprr1   )r   ZextcodeÚopcoder‚  rA   Ús1rY   Ús2r   r   r   Úproduce_global_extê  s&    

z&AbstractPickleTests.produce_global_extc             C   s    |   dtj¡ |   dtj¡ d S )Nr   rP   )r  r   ZEXT1)r   r   r   r   Útest_global_ext1  s    z$AbstractPickleTests.test_global_ext1c             C   s.   |   dtj¡ |   dtj¡ |   dtj¡ d S )Nr[  iÿÿ  iÍ«  )r  r   ZEXT2)r   r   r   r   Útest_global_ext2
  s    z$AbstractPickleTests.test_global_ext2c             C   s.   |   dtj¡ |   dtj¡ |   dtj¡ d S )Ni   iÿÿÿiïÍ«)r  r   ZEXT4)r   r   r   r   Útest_global_ext4  s    z$AbstractPickleTests.test_global_ext4c             C   sÐ   d}t t|ƒƒ}xJtD ]B}|  ||¡}|  |¡}|  ||¡ ttj|ƒ}|  	||dk¡ qW d}t t|ƒƒ}x^tD ]V}|  ||¡}|  |¡}|  ||¡ ttj|ƒ}|dkrº|  	|d¡ qr|  
|dk¡ qrW d S )Né
   r   iÄ	  rO   )r‹   rŠ   r!  r"  rh   rd   r   r   ÚAPPENDSr_   rD  )r   r   rA   r#  r$  rY   Znum_appendsr   r   r   Útest_list_chunking  s$    



z&AbstractPickleTests.test_list_chunkingc             C   sà   d}t  t|ƒ¡}xVtD ]N}|  ||¡}|  |t¡ |  |¡}|  ||¡ t	t
j|ƒ}|  ||dk¡ qW d}t  t|ƒ¡}x^tD ]V}|  ||¡}|  |¡}|  ||¡ t	t
j|ƒ}|dkrÊ|  |d¡ q‚|  |dk¡ q‚W d S )Nr¡  r   iÄ	  rO   )rK   rK  rŠ   r!  r"  r.  r   rh   rd   r   r   ÚSETITEMSr_   rD  )r   r   rA   r#  r$  rY   Znum_setitemsr   r   r   Útest_dict_chunking*  s&    



z&AbstractPickleTests.test_dict_chunkingc             C   sà   d}t t|ƒƒ}x\tD ]T}|  ||¡}|  |¡}|  ||¡ ttj|ƒ}|dk r^|  	|d¡ q|  	|d¡ qW d}t t|ƒƒ}x\tD ]T}|  ||¡}|  |¡}|  ||¡ ttj|ƒ}|dk rÌ|  	|d¡ q„|  
|d¡ q„W d S )Nr¡  rÇ   r   r   iÄ	  rO   )rˆ   rŠ   r!  r"  rh   rd   r   r   ZADDITEMSr_   ÚassertGreaterEqual)r   r   rA   r#  r$  rY   Znum_additemsr   r   r   Útest_set_chunkingA  s(    



z%AbstractPickleTests.test_set_chunkingc          
   C   sª   t  t d¡}d|_x’tD ]Š}| j|dt |  ||¡}|dk rL|  d|¡ n|  d|¡ |  tt	j
|ƒd|k¡ |  tt	j|ƒ¡ |  |¡}|  ||¡ W d Q R X qW d S )NiÎú  iš  )r#  r   s   
I64206s   MÎúrO   )r“  r”  rR   r!  rf   r"  r{  r_   r   r   ÚNEWOBJr˜  Ú	NEWOBJ_EXrh   rd   )r   rA   r#  r$  rY   r   r   r   Útest_simple_newobjZ  s    


z&AbstractPickleTests.test_simple_newobjc          
   C   sÖ   t  t d¡}d|_x¾tD ]¶}| j|d  |  ||¡}|dk rL|  d|¡ n8|dk rb|  d|¡ n"|dk rx|  d	|¡ n|  d
|¡ |  tt	j
|ƒd|k¡ |  tt	j|ƒ¡ |  |¡}|  ||¡ W d Q R X qW d S )NiÎú  iš  )r#  r   s   
I64206rO   s   MÎúrÇ   s	   X   FACEs   ŒFACE)ÚComplexNewObjr”  rR   r!  rf   r"  r{  r_   r   r   r¨  r˜  r©  rh   rd   )r   rA   r#  r$  rY   r   r   r   Útest_complex_newobjj  s"    


z'AbstractPickleTests.test_complex_newobjc          
   C   sÖ   t  t d¡}d|_x¾tD ]¶}| j|d  |  ||¡}|dk rL|  d|¡ n8|dk rb|  d|¡ n"|dk rx|  d	|¡ n|  d
|¡ |  tt	j
|ƒ¡ |  tt	j|ƒd|k¡ |  |¡}|  ||¡ W d Q R X qW d S )NiÎú  iš  )r#  r   s   
I64206rO   s   MÎúrÇ   s	   X   FACEs   ŒFACE)ÚComplexNewObjExr”  rR   r!  rf   r"  r{  r˜  r   r   r¨  r_   r©  rh   rd   )r   rA   r#  r$  rY   r   r   r   Útest_complex_newobj_ex~  s"    


z*AbstractPickleTests.test_complex_newobj_exc             C   s@   t dddgƒ}d|_d|_|  |d¡}|  |¡}|  ||¡ d S )Nr   rO   rÆ   rÃ   r…  )ÚSlotListrT   rU   r"  rh   rd   )r   rA   r$  rY   r   r   r   Útest_newobj_list_slots’  s    
z*AbstractPickleTests.test_newobj_list_slotsc             C   sX   xRt D ]J}tƒ }|  |jd¡ |  ||¡}|  |jd¡ |  |¡}|  |jd¡ qW d S )Nr   r   )r!  ÚREX_oner_   Ú_reduce_calledr"  rh   )r   r#  rA   r$  rY   r   r   r   Ú'test_reduce_overrides_default_reduce_exš  s    

z;AbstractPickleTests.test_reduce_overrides_default_reduce_exc             C   sX   xRt D ]J}tƒ }|  |jd ¡ |  ||¡}|  |j|¡ |  |¡}|  |jd ¡ qW d S )N)r!  ÚREX_twor_   Ú_protor"  rh   )r   r#  rA   r$  rY   r   r   r   Útest_reduce_ex_called£  s    

z)AbstractPickleTests.test_reduce_ex_calledc             C   sX   xRt D ]J}tƒ }|  |jd ¡ |  ||¡}|  |j|¡ |  |¡}|  |jd ¡ qW d S )N)r!  Ú	REX_threer_   rµ  r"  rh   )r   r#  rA   r$  rY   r   r   r   Útest_reduce_ex_overrides_reduce¬  s    

z3AbstractPickleTests.test_reduce_ex_overrides_reducec             C   sX   xRt D ]J}tƒ }|  |jd ¡ |  ||¡}|  |j|¡ |  |¡}|  |j|¡ qW d S )N)r!  ÚREX_fourr_   rµ  r"  rh   )r   r#  rA   r$  rY   r   r   r   Útest_reduce_ex_calls_baseµ  s    

z-AbstractPickleTests.test_reduce_ex_calls_basec             C   sX   xRt D ]J}tƒ }|  |jd¡ |  ||¡}|  |jd¡ |  |¡}|  |jd¡ qW d S )Nr   r   )r!  ÚREX_fiver_   r²  r"  rh   )r   r#  rA   r$  rY   r   r   r   Útest_reduce_calls_base¾  s    

z*AbstractPickleTests.test_reduce_calls_basec             C   s*   t ƒ }xtD ]}|  t| j||¡ qW d S )N)Ú
BadGetattrr!  rg   ÚRuntimeErrorr"  )r   rA   r#  r   r   r   Útest_bad_getattrÇ  s    
z$AbstractPickleTests.test_bad_getattrc          	   C   s†   G dd„ dt ƒ}G dd„ dt ƒ}x`tD ]X}y|  |ƒ |¡ W n tjk
rR   Y nX y|  |ƒ |¡ W q& tjk
r|   Y q&X q&W d S )Nc               @   s   e Zd Zdd„ ZdS )z7AbstractPickleTests.test_reduce_bad_iterator.<locals>.Cc             S   s   t dd g d fS )Nr   )r‹   )r   r   r   r   r=   Ò  s    zBAbstractPickleTests.test_reduce_bad_iterator.<locals>.C.__reduce__N)r&   r'   r(   r=   r   r   r   r   r2   Ñ  s   r2   c               @   s   e Zd Zdd„ ZdS )z7AbstractPickleTests.test_reduce_bad_iterator.<locals>.Dc             S   s   t dd d g fS )Nr   )rK   )r   r   r   r   r=   Ö  s    zBAbstractPickleTests.test_reduce_bad_iterator.<locals>.D.__reduce__N)r&   r'   r(   r=   r   r   r   r   r6   Õ  s   r6   )r“   r!  r"  r   ÚPicklingError)r   r2   r6   r#  r   r   r   Útest_reduce_bad_iteratorÎ  s    
z,AbstractPickleTests.test_reduce_bad_iteratorc          
   C   s†   dd„ t dƒD ƒ}tdd„ |D ƒƒ}t|ƒt|ƒt|ƒg}xFtD ]>}| j|d( |  ||¡}|  |¡}|  ||¡ W d Q R X q@W d S )Nc             s   s   | ]}d t |ƒ V  qdS )ZaaaN)r@   )r  rB  r   r   r   ú	<genexpr>è  s    z>AbstractPickleTests.test_many_puts_and_gets.<locals>.<genexpr>r­   c             s   s   | ]}|d ddgfV  qdS )rÇ   rS   rÈ   Nr   )r  r6  r   r   r   rÂ  é  s    )r#  )rŠ   rK   r!  rf   r"  rh   rd   )r   r   Z
large_dictrc   r#  r¥   r˜   r   r   r   Útest_many_puts_and_getså  s    

z+AbstractPickleTests.test_many_puts_and_getsc       	      C   sr   xlt D ]d}tƒ }d|_d|_|  ||¡}|  |¡}t|jƒ}t|jƒ}x"t||ƒD ]\}}|  	||¡ qRW qW d S )NrÃ   r…  )
r!  r2   rT   rU   r"  rh   Úsortedr3   Úzipr`   )	r   r#  rA   r$  rY   Zx_keysZy_keysZx_keyZy_keyr   r   r   Útest_attribute_name_interningò  s    



z1AbstractPickleTests.test_attribute_name_interningc             C   s>   |   tdƒd¡}|  |t¡ |   tdgƒd¡}|  |t¡ d S )NrS   rO   rÆ   )r"  rŠ   r_   r‰   rˆ   Ú	DATA_SET2)r   r¥   r   r   r   Útest_pickle_to_2x   s    z%AbstractPickleTests.test_pickle_to_2xc             C   sX   xRt D ]J}dtdd tf}|  ||¡}|  |¡}|  t|ƒt|ƒ¡ |  ||¡ qW d S )Nr   s   xyi x  )r!  r€  r/  r"  rh   r_   )r   r#  re   r¥   r˜   r   r   r   Útest_large_pickles
  s    

z&AbstractPickleTests.test_large_picklesc          
      sˆ   x‚t D ]z‰ ˆjˆ dd ‡ ‡fdd„tdƒD ƒ}ttt|ƒƒ}ˆ t|ƒ|¡ ˆ dkrvx|D ]}ˆ t	t
j|ƒ¡ q\W W d Q R X qW d S )N)r#  c                s   g | ]}ˆ  d | ˆ ¡‘qS )rO   )r"  )r  r   )r#  r   r   r   r    s    zDAbstractPickleTests.test_int_pickling_efficiency.<locals>.<listcomp>éF   rO   )r!  rf   rŠ   r‹   Úmapr/  r_   rÄ  r˜  r   r   ZLONG)r   ZpicklesZsizesr¾   r   )r#  r   r   Útest_int_pickling_efficiency  s    

z0AbstractPickleTests.test_int_pickling_efficiencyc             C   s6   |   ||¡}|  t||ƒ¡ |  |¡}|  ||¡ d S )N)r"  rD  r   rh   r_   )r   rc   rš  r#  r´   rµ   r   r   r   Ú_check_pickling_with_opcode   s    
z/AbstractPickleTests._check_pickling_with_opcodec             C   sJ   t dddgƒ}x6tD ].}|dkr2|  |tj|¡ q|  |tj|¡ qW d S )Nr   rO   rÆ   r   )ÚREX_sixr!  rÍ  r   ZAPPENDr¢  )r   rc   r#  r   r   r   Útest_appends_on_non_lists&  s
    
z-AbstractPickleTests.test_appends_on_non_listsc             C   sL   t ddddœƒ}x6tD ].}|dkr4|  |tj|¡ q|  |tj|¡ qW d S )NrQ   éþÿÿÿéýÿÿÿ)r   rO   rÆ   r   )Ú	REX_sevenr!  rÍ  r   ZSETITEMr¤  )r   rc   r#  r   r   r   Útest_setitems_on_non_dicts/  s
    
z.AbstractPickleTests.test_setitems_on_non_dictsrÇ   i   c             C   s>  d  }}ddddh}xèt  |¡D ]Ú\}}}|d k	rJ|  ||¡ ||krJd }|d k	r~|  |jd¡ |j|krÖ|  t|ƒ| j¡ nX|jdks |j|krÀt|ƒ| jkrÀ|d k	rÖ|  || | j¡ d }n|d krÖ|jdkrÖ|}|jdkr |  	|| j¡ |d | }q W t|ƒ}|d k	r|  
||¡ n|d k	r:|  || | j¡ d S )NÚBINBYTESÚ
BINUNICODEÚ	BINBYTES8ÚBINUNICODE8ÚFRAMErx  é	   )r   r   ÚassertLessEqualÚassertNotEqualrL   r/  ÚFRAME_SIZE_TARGETÚ
assertLessÚFRAME_SIZE_MINr¦  r_   )r   r´   Z	frame_endZframeless_startZframeless_opcodesr   r7   Úposr   r   r   Úcheck_frame_opcodes<  s8    






z'AbstractPickleTests.check_frame_opcodesc          
   C   s¦   t tdƒƒ}x”tdtjd ƒD ]€}| j|dj |  ||¡}|  |¡}|  ||¡ t|ƒt	tj
|ƒ }|  || jd ¡ |  || jd ¡ |  |¡ W d Q R X qW d S )Ni † rÇ   r   )r#  rO   )r‹   rŠ   r   r9  rf   r"  rh   r_   r/  r   rØ  ÚassertGreaterrÜ  rÚ  rà  )r   rc   r#  r´   rµ   Zbytes_per_framer   r   r   Útest_framing_many_objectsj  s    
z-AbstractPickleTests.test_framing_many_objectsc             C   s  d}dd„ t dƒD ƒ}d| f|d| d| f•}xät dtjd	 ƒD ]Ð}xÊd
D ]Â}| j||dª |st|  ||¡}n:t| dƒs€wNt ¡ }| j||d}||_	| 
|¡ | ¡ }|  |¡}	|  dd„ |D ƒdd„ |	D ƒ¡ |  ||	¡ ttj|ƒ}
|  |
d	¡ |  |¡ W d Q R X qNW qDW d S )Ni   c             S   s   g | ]
}|g‘qS r   r   )r  rB  r   r   r   r  {  s    zBAbstractPickleTests.test_framing_large_objects.<locals>.<listcomp>r¡  ó   xó   yÚzrÇ   r   )FT)r#  ÚfastÚpickler)Úprotocolc             S   s   g | ]}t |ƒ‘qS r   )r/  )r  rA   r   r   r   r    s    c             S   s   g | ]}t |ƒ‘qS r   )r/  )r  rA   r   r   r   r    s    )rŠ   r   r9  rf   r"  ra   r"   ÚBytesIOrç  ræ  Údumpr,  rh   r_   r   rØ  rà  )r   ÚNZsmall_itemsrc   r#  ræ  r´   Úbufrç  rµ   Ún_framesr   r   r   Útest_framing_large_objectsy  s,    



z.AbstractPickleTests.test_framing_large_objectsc                sÌ   t jdk rd S ddd„}| j‰ d}‡ fdd„t|ƒD ƒ}xŽtdt jd ƒD ]z}|  ||¡}||ƒ}|  tt j|ƒd¡ |  ||  |¡¡ ||d	d
„ ƒ}|  	tt j|ƒtt j|ƒ¡ |  ||  |¡¡ qJW d S )NrÇ   c       
      S   s   g }d}x,t  | ¡D ]\}}}|jdkr| |¡ qW tƒ }d}x:t|ƒD ].\}	}|r`||	ƒr`qJ|| ||… 7 }|| }qJW || |d … 7 }|S )NrÙ  rØ  r   )r   r   rL   rW   Ú	bytearrayÚ	enumerate)
r´   Z
keep_frameZframe_startsZframe_opcode_sizerš  Ú_rß  Z	newpickleZlast_frame_endrB  r   r   r   Úremove_frames  s    
z?AbstractPickleTests.test_optional_frames.<locals>.remove_framesé   c                s   i | ]}t |gƒˆ  |“qS r   )rš   )r  rB  )Ú
frame_sizer   r   ú
<dictcomp>´  s    z<AbstractPickleTests.test_optional_frames.<locals>.<dictcomp>r   r   c             S   s   | d S )NrO   r   )rB  r   r   r   Ú<lambda>½  rê   z:AbstractPickleTests.test_optional_frames.<locals>.<lambda>)N)
r   r9  rÜ  rŠ   r"  r_   r   rØ  rh   rÝ  )r   rò  Z
num_framesrc   r#  r´   Zframeless_pickleZsome_frames_pickler   )rô  r   Útest_optional_frames™  s    

z(AbstractPickleTests.test_optional_framesc                sŠ  G dd„ dƒ}xtt dtjd ƒD ]^}dd„ t tdƒƒD ƒ}| dˆ jd	 d  ¡ |ƒ }ˆ  ||¡ |¡ | ¡ }ˆ  	|¡}ˆ  
||¡ ˆ  t|jƒd¡ ~t ¡  ˆ  
| ¡ |¡ t|ƒd ˆ j d }ˆ  t|jƒ|¡ ˆ  t|jƒd
| d ¡ dd„ |jD ƒ}‡ fdd„|D ƒ}	‡ fdd„|D ƒ}
dd„ |D ƒ}x"|	D ]}ˆ  |d
ˆ j |¡ qBW ˆ  t|ƒt|	ƒt|
ƒ d |¡ q"W d S )Nc               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )zYAbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.ChunkAccumulatorc             S   s
   g | _ d S )N)Úchunks)r   r   r   r   r.   Å  s    zbAbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.ChunkAccumulator.__init__c             S   s   | j  |¡ d S )N)rø  rW   )r   Úchunkr   r   r   r  Ç  s    z_AbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.ChunkAccumulator.writec             S   s   d  | j¡S )Nrê   )r  rø  )r   r   r   r   Úconcatenate_chunksÉ  s    zlAbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.ChunkAccumulator.concatenate_chunksN)r&   r'   r(   r.   r  rú  r   r   r   r   ÚChunkAccumulatorÃ  s   rû  rÇ   r   c             S   s,   g | ]$}t |ƒ d ¡|d dt |ƒif‘qS )r{   rÃ   rB  )r@   r}   )r  rB  r   r   r   r  Í  s   zSAbstractPickleTests.test_framed_write_sizes_with_delayed_writer.<locals>.<listcomp>g     ˆÃ@Z0123456789abcdefr`  rO   rÆ   c             S   s   g | ]}t |ƒ‘qS r   )r/  )r  rX   r   r   r   r  ñ  s    c                s   g | ]}|ˆ j kr|‘qS r   )rÜ  )r  r$  )r   r   r   r  ò  s    c                s*   g | ]"}d |  k rˆ j k rn q|‘qS )rÙ  )rÜ  )r  r$  )r   r   r   r  ô  s    c             S   s   g | ]}|d kr|‘qS )rÙ  r   )r  r$  r   r   r   r  ö  s    )rŠ   r   r9  ra  rW   rÜ  rç  rê  rú  rh   r_   rá  r/  rø  r   Z
gc_collectr¦  rÚ  rÝ  )r   rû  r#  ZobjectsÚwriterr´   Zreconstructedrí  Zchunk_sizesZlarge_sizesZmedium_sizesZsmall_sizesZ
chunk_sizer   )r   r   Ú+test_framed_write_sizes_with_delayed_writerÂ  s8    	


z?AbstractPickleTests.test_framed_write_sizes_with_delayed_writerc             C   s‚   G dd„ dƒa xnttjd ƒD ]\}xVt jt jjt jjjgD ]<}| j||d$ |  |  	||¡¡}|  
||¡ W d Q R X q:W qW d S )Nc               @   s   e Zd ZG dd„ dƒZdS )ÚNestedc               @   s   e Zd ZG dd„ dƒZdS )zNested.Ac               @   s   e Zd ZG dd„ dƒZdS )z
Nested.A.Bc               @   s   e Zd ZdS )zNested.A.B.CN)r&   r'   r(   r   r   r   r   r2   	  s   r2   N)r&   r'   r(   r2   r   r   r   r   r‹  	  s   r‹  N)r&   r'   r(   r‹  r   r   r   r   ÚA	  s   rÿ  N)r&   r'   r(   rÿ  r   r   r   r   rþ  	  s   rþ  r   )r#  rc   )rþ  rŠ   r   r9  rÿ  r‹  r2   rf   rh   r"  r`   )r   r#  rc   rµ   r   r   r   Útest_nested_names	  s    z%AbstractPickleTests.test_nested_namesc          
   C   sx   G dd„ dƒa tjt j t _dt _xLttjd ƒD ]:}| j	|d$ |  
|  t |¡¡}|  |t ¡ W d Q R X q2W t `d S )Nc               @   s   e Zd ZdS )Ú	RecursiveN)r&   r'   r(   r   r   r   r   r  	  s   r  zRecursive.mod.Recursiver   )r#  )r  r  Úmodulesr'   Úmodr(   rŠ   r   r9  rf   rh   r"  r`   )r   r#  rµ   r   r   r   Útest_recursive_nested_names	  s    z/AbstractPickleTests.test_recursive_nested_namesc             C   s
  G dd„ dƒa t jt jt ƒ jt jjt jjt  ¡ jf}t jt ft jjt jff}x¸tt	j
d ƒD ]¦}xH|D ]@}| j||d( |  |  ||¡¡}|  |ƒ |ƒ ¡ W d Q R X qfW xV|D ]N\}}|ƒ }| j||d, |  |  ||¡¡}|  ||ƒ||ƒ¡ W d Q R X q°W q\W d S )Nc               @   s:   e Zd Zedd„ ƒZedd„ ƒZdd„ ZG dd„ dƒZd	S )
ÚPyMethodsTestc               S   s   dS )NÚcheeser   r   r   r   r   r  	  s    zPyMethodsTest.cheesec             S   s   dS )NÚwiner   )Úclsr   r   r   r  "	  s    zPyMethodsTest.winec             S   s   dS )NÚbiscuitsr   )r   r   r   r   r	  &	  s    zPyMethodsTest.biscuitsc               @   s,   e Zd Zedd„ ƒZedd„ ƒZdd„ ZdS )zPyMethodsTest.Nestedc               S   s   dS )NÚketchupr   r   r   r   r   r
  +	  s    zPyMethodsTest.Nested.ketchupc             S   s   dS )NÚmapler   )r  r   r   r   r  .	  s    zPyMethodsTest.Nested.maplec             S   s   dS )NÚpier   )r   r   r   r   r  2	  s    zPyMethodsTest.Nested.pieN)r&   r'   r(   Ústaticmethodr
  Úclassmethodr  r  r   r   r   r   rþ  )	  s   rþ  N)	r&   r'   r(   r  r  r  r  r	  rþ  r   r   r   r   r  	  s   r  r   )r#  Úmethod)r  r  r  r	  rþ  r
  r  r  rŠ   r   r9  rf   rh   r"  r_   )r   Z
py_methodsZpy_unbound_methodsr#  r  rµ   r  rc   r   r   r   Útest_py_methods	  s&    
z#AbstractPickleTests.test_py_methodsc             C   s&  G dd„ dt ƒadjdftjdfdddgjd	ftjdddgffddhjd
ftjddhdfftj	dft
jdftdddgƒjd
ftjtdddgƒdfft d¡jdftjjt d¡dfff}xhttjd ƒD ]V}xP|D ]H\}}| j||d, |  |  ||¡¡}|  ||Ž ||Ž ¡ W d Q R X qÒW qÈW d S )Nc               @   s   e Zd ZG dd„ deƒZdS )ÚSubclassc               @   s   e Zd ZdS )zSubclass.NestedN)r&   r'   r(   r   r   r   r   rþ  P	  s   rþ  N)r&   r'   r(   r@   rþ  r   r   r   r   r  O	  s   r  Úabcd)rX   )r  rX   r   rO   rÆ   r   )rO   ))rC   r   )rD   rO   )s   abcs   xyzZsweet)r‚  r‚  )r#  r  )r2  r  Úindexr@   Ú__len__r‹   Ú__contains__rˆ   rK   rK  rï  Ú	maketransÚcountrþ  rŠ   r   r9  rf   rh   r"  r_   )r   Z	c_methodsr#  r  r   rµ   r   r   r   Útest_c_methodsM	  s$    z"AbstractPickleTests.test_c_methodsc             C   sè   t ddƒddfttdƒddftjddftjd	d	ftƒ d
dft 	¡ ddft 
¡ ddft ¡ ddfg}x€|D ]x\}}}xlt dƒD ]`}| jt|ƒ|dD |  ||¡}|  d||f  ¡ |¡ |  t|  |¡ƒt|ƒ¡ W d Q R X q|W qhW d S )Nr   rÅ   Z__builtin__ZxrangeZ123Ú	itertoolsZimaprÊ   rÌ   Ú
exceptionsr   rÎ   ZIterableUserDictÚUserListrÍ   ÚdefaultdictrÆ   )rH   r#  zc%s
%s)rŠ   rË  ra  rÉ   rÊ   rË   rÌ   r   rÍ   rÎ   r  r  rf   rH   r"  r{  r}   r`   rh   )r   ZtestsÚvalr  rL   r#  r´   r   r   r   Útest_compat_picklep	  s    


z&AbstractPickleTests.test_compat_picklec          
   C   sð   dd„ }xFt dtjd ƒD ]2}|  ttjf¡ t |  ||¡¡ W d Q R X qW |`	xFt dtjd ƒD ]2}|  ttjf¡ t |  ||¡¡ W d Q R X qfW |j
|_xFt dtjd ƒD ]2}|  ttjf¡ t |  ||¡¡ W d Q R X q¶W d S )Nc               S   s   d S )Nr   r   r   r   r   r  …	  s    z6AbstractPickleTests.test_local_lookup_error.<locals>.fr   r   )rŠ   r   r9  rg   ÚAttributeErrorrÀ  r   r(  r"  r'   r(   r&   )r   r  r#  r   r   r   Útest_local_lookup_error‚	  s      z+AbstractPickleTests.test_local_lookup_errorN)br&   r'   r(   Z	optimizedr[   rp   r   rd   r%  r&  r-  r1  r3  r5  r7  r:  r<  r>  r?  rC  rE  rH  rI  rJ  rL  rM  rO  rP  rR  rS  rU  rW  rY  rZ  r\  r^  rb  rc  r   rg  rk  rl  rm  rn  rs  rt  rv  rw  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   r  Û  s¸   






	'							

	
. )A1#r  c               @   sz   e Zd Zeeddddd„ ƒZeeddddd„ ƒZeedddd	d
„ ƒZeeddddd„ ƒZ	eeddddd„ ƒZ
dS )ÚBigmemPickleTestsgÍÌÌÌÌÌ@F)ÚsizeZmemuseZdry_runc             C   st   dd| > }z\xVt D ]N}|dk r"q| j|d. |  ttf¡ | j||d W d Q R X W d Q R X qW W d d }X d S )Nr   r_  rO   )r#  )rè  )r!  rf   rg   r‚   r©   r"  )r   r"  re   r#  r   r   r   Útest_huge_long_32bœ	  s    
*z$BigmemPickleTests.test_huge_long_32bg      @c          
   C   s¢   d|d  }zŠx„t D ]|}|dk r"q| j|d\ zN| j||d}tjt dt|ƒ¡ }| |¡}|  	|||t|ƒ |… ¡ W d d }X W d Q R X qW W d d }X d S )Ns   abcdrÇ   rÆ   )r#  )rè  z<I)
r!  rf   r"  r   rÔ  r   rž   r/  r  r_   )r   r"  re   r#  r´   ÚheaderÚ
data_startr   r   r   Útest_huge_bytes_32b­	  s     

z%BigmemPickleTests.test_huge_bytes_32bc             C   sÔ   d|d  }z¼x¶t D ]®}|dk r"q| j|dŽ |dkrb|  ttf¡ | j||d W d Q R X wzN| j||d}tjt 	dt
|ƒ¡ }| |¡}|  |||t
|ƒ |… ¡ W d d }X W d Q R X qW W d d }X d S )Ns   acbdrÇ   rÆ   )r#  )rè  z<Q)r!  rf   rg   r‚   r©   r"  r   rÖ  r   rž   r/  r  r_   )r   r"  re   r#  r´   r$  r%  r   r   r   Útest_huge_bytes_64bÂ	  s(    

z%BigmemPickleTests.test_huge_bytes_64br_  c          
   C   sÊ   d|d  }z²x¬t D ]¤}|dkr"q| j|d„ zv| j||d}tjt dt|ƒ¡ }| d¡}|  	|||t|ƒ |… ¡ |  	| 
d¡tdƒ | d¡ t|ƒ¡ W d d }X W d Q R X qW W d d }X d S )Nr  rÇ   r   )r#  )rè  z<Is   abcd)r!  rf   r"  r   rÕ  r   rž   r/  r  r_   Úrindex)r   r"  re   r#  r´   r$  r%  r   r   r   Útest_huge_str_32bà	  s$    

z#BigmemPickleTests.test_huge_str_32bc             C   sü   d|d  }zäxÞt D ]Ö}|dkr"q| j|d¶ |dk rb|  ttf¡ | j||d W d Q R X wzv| j||d}tjt 	dt
|ƒ¡ }| d¡}|  |||t
|ƒ |… ¡ |  | d¡t
dƒ | d¡ t
|ƒ¡ W d d }X W d Q R X qW W d d }X d S )Nr  rÇ   r   )r#  )rè  z<Qs   abcd)r!  rf   rg   r‚   r©   r"  r   r×  r   rž   r/  r  r_   r(  )r   r"  re   r#  r´   r$  r%  r   r   r   Útest_huge_str_64bû	  s,    

z#BigmemPickleTests.test_huge_str_64bN)r&   r'   r(   r   r	   r#  r&  r
   r'  r)  r*  r   r   r   r   r!  ˜	  s
   r!  c               @   s   e Zd ZdZdd„ ZdS )r±  r   c             C   s   d| _ tdfS )Nr   r   )r²  r±  )r   r   r   r   r=   
  s    zREX_one.__reduce__N)r&   r'   r(   r²  r=   r   r   r   r   r±  
  s   r±  c               @   s   e Zd ZdZdd„ ZdS )r´  Nc             C   s   || _ tdfS )Nr   )rµ  r´  )r   r#  r   r   r   Ú__reduce_ex__#
  s    zREX_two.__reduce_ex__)r&   r'   r(   rµ  r+  r   r   r   r   r´   
  s   r´  c               @   s    e Zd ZdZdd„ Zdd„ ZdS )r·  Nc             C   s   || _ tdfS )Nr   )rµ  r´  )r   r#  r   r   r   r+  )
  s    zREX_three.__reduce_ex__c             C   s   t dƒ‚d S )Nz#This __reduce__ shouldn't be called)r   )r   r   r   r   r=   ,
  s    zREX_three.__reduce__)r&   r'   r(   rµ  r+  r=   r   r   r   r   r·  '
  s   r·  c               @   s   e Zd ZdZdd„ ZdS )r¹  Nc             C   s   || _ t | |¡S )N)rµ  r“   r+  )r   r#  r   r   r   r+  2
  s    zREX_four.__reduce_ex__)r&   r'   r(   rµ  r+  r   r   r   r   r¹  /
  s   r¹  c               @   s   e Zd ZdZdd„ ZdS )r»  r   c             C   s   d| _ t | ¡S )Nr   )r²  r“   r=   )r   r   r   r   r=   9
  s    zREX_five.__reduce__N)r&   r'   r(   r²  r=   r   r   r   r   r»  6
  s   r»  c               @   s.   e Zd Zd
dd„Zdd„ Zdd„ Zdd	„ ZdS )rÎ  Nc             C   s   |d k	r|ng | _ d S )N)Úitems)r   r,  r   r   r   r.   A
  s    zREX_six.__init__c             C   s   t | ƒt |ƒko| j|jkS )N)rH   r,  )r   r4   r   r   r   r5   C
  s    zREX_six.__eq__c             C   s   | j  |¡ d S )N)r,  rW   )r   Úitemr   r   r   rW   E
  s    zREX_six.appendc             C   s   t | ƒdd t| jƒd fS )Nr   )rH   Úiterr,  )r   r   r   r   r=   G
  s    zREX_six.__reduce__)N)r&   r'   r(   r.   r5   rW   r=   r   r   r   r   rÎ  =
  s   
rÎ  c               @   s.   e Zd Zd
dd„Zdd„ Zdd„ Zdd	„ ZdS )rÒ  Nc             C   s   |d k	r|ni | _ d S )N)Útable)r   r/  r   r   r   r.   N
  s    zREX_seven.__init__c             C   s   t | ƒt |ƒko| j|jkS )N)rH   r/  )r   r4   r   r   r   r5   P
  s    zREX_seven.__eq__c             C   s   || j |< d S )N)r/  )r   r…   r<   r   r   r   Ú__setitem__R
  s    zREX_seven.__setitem__c             C   s   t | ƒdd d t| j ¡ ƒfS )Nr   )rH   r.  r/  r,  )r   r   r   r   r=   T
  s    zREX_seven.__reduce__)N)r&   r'   r(   r.   r5   r0  r=   r   r   r   r   rÒ  J
  s   
rÒ  c               @   s   e Zd ZdZdS )rŽ  r   N)r&   r'   r(   rŠ  r   r   r   r   rŽ  Z
  s   rŽ  c               @   s   e Zd ZdZdS )ÚMyFloatg      ð?N)r&   r'   r(   rŠ  r   r   r   r   r1  ]
  s   r1  c               @   s   e Zd ZdZdS )Ú	MyComplexy      ð?        N)r&   r'   r(   rŠ  r   r   r   r   r2  `
  s   r2  c               @   s   e Zd ZdZdS )ÚMyStrr…  N)r&   r'   r(   rŠ  r   r   r   r   r3  c
  s   r3  c               @   s   e Zd ZdZdS )Ú	MyUnicodeu	   hello áˆ´N)r&   r'   r(   rŠ  r   r   r   r   r4  f
  s   r4  c               @   s   e Zd ZdZdS )rQ  )r   rO   rÆ   N)r&   r'   r(   rŠ  r   r   r   r   rQ  i
  s   rQ  c               @   s   e Zd ZdddgZdS )r;  r   rO   rÆ   N)r&   r'   r(   rŠ  r   r   r   r   r;  l
  s   r;  c               @   s   e Zd ZdddœZdS )r=  r   rO   )rC   rD   N)r&   r'   r(   rŠ  r   r   r   r   r=  o
  s   r=  c               @   s   e Zd ZddhZdS )rT  rC   rD   N)r&   r'   r(   rŠ  r   r   r   r   rT  r
  s   rT  c               @   s   e Zd ZeddhƒZdS )rV  rC   rD   N)r&   r'   r(   rN  rŠ  r   r   r   r   rV  u
  s   rV  c               @   s   e Zd ZdgZdS )r¯  rT   N)r&   r'   r(   r]   r   r   r   r   r¯  ~
  s   r¯  c               @   s   e Zd Zdd„ Zdd„ ZdS )r“  c             O   s   t dƒ‚d S )Nz3SimpleNewObj.__init__() didn't expect to get called)r•  )r   r   Úkwargsr   r   r   r.   ‚
  s    zSimpleNewObj.__init__c             C   s   t | ƒt |ƒko| j|jkS )N)ra  r3   )r   r4   r   r   r   r5   …
  s    zSimpleNewObj.__eq__N)r&   r'   r(   r.   r5   r   r   r   r   r“  
  s   r“  c               @   s   e Zd Zdd„ ZdS )r«  c             C   s   d|  dfS )Nz%Xr`  r   )r   r   r   r   Ú__getnewargs__‰
  s    zComplexNewObj.__getnewargs__N)r&   r'   r(   r6  r   r   r   r   r«  ˆ
  s   r«  c               @   s   e Zd Zdd„ ZdS )r­  c             C   s   d|  fddifS )Nz%XÚbaser`  r   )r   r   r   r   Ú__getnewargs_ex__
  s    z!ComplexNewObjEx.__getnewargs_ex__N)r&   r'   r(   r8  r   r   r   r   r­  Œ
  s   r­  c               @   s   e Zd Zdd„ ZdS )r½  c             C   s
   | j  d S )N)rT   )r   r…   r   r   r   Ú__getattr__‘
  s    zBadGetattr.__getattr__N)r&   r'   r(   r9  r   r   r   r   r½  
  s   r½  c               @   sL   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dS )ÚAbstractPickleModuleTestsc          	   C   s:   t tdƒ}z| ¡  |  t| jd|¡ W d t t¡ X d S )Nr  é{   )r  r   Úcloserg   r‚   rê  r   Úunlink)r   r  r   r   r   Útest_dump_closed_file—
  s
    
z/AbstractPickleModuleTests.test_dump_closed_filec          	   C   s:   t tdƒ}z| ¡  |  t| jd|¡ W d t t¡ X d S )Nr  r;  )r  r   r<  rg   r‚   rê  r   r=  )r   r  r   r   r   Útest_load_closed_fileŸ
  s
    
z/AbstractPickleModuleTests.test_load_closed_filec             C   sB   t  ¡ }di dg}|  ||¡ | d¡ |  |¡}|  ||¡ d S )Nr;  é|   r   )r"   ré  rê  r$   Úloadr_   )r   Ústreamre   rµ   r   r   r   Útest_load_from_and_dump_to_file§
  s    


z9AbstractPickleModuleTests.test_load_from_and_dump_to_filec             C   s   |   tjd¡ d S )NrÇ   )r_   r   r9  )r   r   r   r   Útest_highest_protocol¯
  s    z/AbstractPickleModuleTests.test_highest_protocolc             C   s^   t  ¡ }|  d|d¡ | jd|dd |  dd¡ | jddd |  |d¡ | j|dd d S )Nr;  rQ   )Úfilerè  )rè  )r"   ré  rê  r"  ÚPickler)r   r  r   r   r   Útest_callapi³
  s    z&AbstractPickleModuleTests.test_callapic          	   C   sJ   t tdƒ}z&x tD ]}|  t| jd||¡ qW W d | ¡  t t¡ X d S )NÚwr;  )	r  r   r!  rg   r•  rê  r<  r   r=  )r   r  r#  r   r   r   Útest_dump_text_file½
  s    

z-AbstractPickleModuleTests.test_dump_text_filec             C   s(   t  d¡}|  ttjtjf| j|¡ d S )Ns   X''.)	r"   ré  rg   r  r   Úerrorr   r¨   rA  )r   r$  r   r   r   Útest_incomplete_inputÆ
  s    
z/AbstractPickleModuleTests.test_incomplete_inputc             C   sN   G dd„ d| j ƒ}G dd„ d| jƒ}|  tj|ƒ jd¡ |  tj|ƒ j¡ d S )Nc               @   s   e Zd Zdd„ ZdS )z;AbstractPickleModuleTests.test_bad_init.<locals>.BadPicklerc             S   s   d S )Nr   )r   r   r   r   r.   Î
  rê   zDAbstractPickleModuleTests.test_bad_init.<locals>.BadPickler.__init__N)r&   r'   r(   r.   r   r   r   r   Ú
BadPicklerÍ
  s   rL  c               @   s   e Zd Zdd„ ZdS )z=AbstractPickleModuleTests.test_bad_init.<locals>.BadUnpicklerc             S   s   d S )Nr   )r   r   r   r   r.   Ñ
  rê   zFAbstractPickleModuleTests.test_bad_init.<locals>.BadUnpickler.__init__N)r&   r'   r(   r.   r   r   r   r   ÚBadUnpicklerÐ
  s   rM  r   )rF  Z	Unpicklerrg   r   rÀ  rê  r¨   rA  )r   rL  rM  r   r   r   Útest_bad_initÊ
  s    z'AbstractPickleModuleTests.test_bad_initN)r&   r'   r(   r>  r?  rC  rD  rG  rI  rK  rN  r   r   r   r   r:  •
  s   
	r:  c               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚAbstractPersistentPicklerTestsc             C   sN   t |tƒr,|d dkr,|  jd7  _t|ƒS |dkrF|  jd7  _dS d S d S )NrO   r   r   Útest_false_valuer¢   )Ú
isinstancera  Úid_countr@   Úfalse_count)r   r“   r   r   r   Úpersistent_idÝ
  s    z,AbstractPersistentPicklerTests.persistent_idc             C   s4   |s|  j d7  _ dS |  jd7  _t|ƒ}|S d S )Nr   rP  )Úload_false_countÚ
load_countra  )r   Zoidr“   r   r   r   Úpersistent_loadç
  s    z.AbstractPersistentPicklerTests.persistent_loadc          	   C   sŽ   t tdƒƒdg }xvtD ]n}d| _d| _d| _d| _|  |  |  	||¡¡|¡ |  | jd¡ |  | jd¡ |  | jd¡ |  | jd¡ qW d S )Nr¡  rP  r   rS   r   )
r‹   rŠ   r!  rR  rS  rU  rV  r_   rh   r"  )r   ÚLr#  r   r   r   Útest_persistenceñ
  s    
z/AbstractPersistentPicklerTests.test_persistenceN)r&   r'   r(   rT  rW  rY  r   r   r   r   rO  ×
  s   

rO  c               @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )Ú&AbstractIdentityPersistentPicklerTestsc             C   s   |S )Nr   )r   rc   r   r   r   rT    s    z4AbstractIdentityPersistentPicklerTests.persistent_idc             C   s   |S )Nr   )r   Úpidr   r   r   rW    s    z6AbstractIdentityPersistentPicklerTests.persistent_loadc             C   s2   |   |  ||¡¡}|  |t|ƒ¡ |  ||¡ d S )N)rh   r"  r.  rH   r_   )r   rc   r#  rµ   r   r   r   Ú_check_return_correct_type  s    zAAbstractIdentityPersistentPicklerTests._check_return_correct_typec             C   sL   xFt D ]>}|dkr |  dd¡ qx"ddddtgD ]}|  ||¡ q0W qW d S )Nr   rR   s   abc
zabc
rQ   g*\Âõ(¼¿)r!  r\  r@   )r   r#  rc   r   r   r   Útest_return_correct_type  s
    
z?AbstractIdentityPersistentPicklerTests.test_return_correct_typec             C   sB   d}|   tj| j|d¡ tj| d¡ d }|   tj| j|¡ d S )Nu   âˆ…r   zutf-8s   
.)rg   r   rÀ  r"  ZPERSIDr}   r¨   rh   )r   Znon_ascii_strr´   r   r   r   Útest_protocol0_is_ascii_only  s    zCAbstractIdentityPersistentPicklerTests.test_protocol0_is_ascii_onlyN)r&   r'   r(   rT  rW  r\  r]  r^  r   r   r   r   rZ  ÿ
  s
   	rZ  c               @   s\   e Zd ZdZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )Ú#AbstractPicklerUnpicklerObjectTestsNc             C   s   d S )Nr   )r   r   r   r   r   !  s    z)AbstractPicklerUnpicklerObjectTests.setUpc             C   sª   dddg}xšt D ]’}t ¡ }|  ||¡}| |¡ | ¡ }| d¡ | ¡  | |¡ | ¡ }| ¡  | d¡ | ¡  | |¡ | ¡ }|  	||¡ |  
||¡ qW d S )NÚabcdefgé,   r   )r!  r"   ré  Úpickler_classrê  r,  r$   ÚtruncateZ
clear_memorÛ  r_   )r   re   r#  r  rç  Úfirst_pickledZsecond_pickledZthird_pickledr   r   r   Útest_clear_pickler_memo%  s"    






z;AbstractPicklerUnpicklerObjectTests.test_clear_pickler_memoc             C   sj   dddg}t  ¡ }|  |¡}| |¡ | ¡ }t  ¡ }|  |¡}|j|_| |¡ | ¡ }|  ||¡ d S )Nr`  ra  )r"   ré  rb  rê  r,  ÚmemorÛ  )r   re   r  rç  rd  ÚprimedÚprimed_pickledr   r   r   Útest_priming_pickler_memoE  s    




z=AbstractPicklerUnpicklerObjectTests.test_priming_pickler_memoc       
      C   sÆ   dddg}t  ¡ }|  |¡}| |¡ | ¡ }t  ¡ }|  |¡}|j|_| |¡ | ¡ }|  t  |¡¡}| ¡ }|  ||¡ |  t  |¡¡}|j|_| ¡ }	|j 	¡  |  |	|¡ |  
|	|k¡ d S )Nr`  ra  )r"   ré  rb  rê  r,  rf  Úunpickler_classrA  r_   ÚclearrD  )
r   re   r  rç  rd  rg  rh  Ú	unpicklerZunpickled_data1Zunpickled_data2r   r   r   Útest_priming_unpickler_memoW  s&    





z?AbstractPicklerUnpicklerObjectTests.test_priming_unpickler_memoc             C   sÌ   dddg}t  ¡ }|  |¡}| |¡ | ¡ }dddg}t  ¡ }|  |¡}| |¡ | ¡ }t  ¡ }| |¡ | d¡ |  |¡}|  | 	¡ |¡ | d¡ | 
¡  | |¡ | d¡ |  | 	¡ |¡ d S )Nr`  ra  r   )r"   ré  rb  rê  r,  r  r$   rj  r_   rA  rc  )r   Údata1r  rç  Zpickled1Zdata2Zpickled2rl  r   r   r   Útest_reusing_unpickler_objectsu  s(    











zBAbstractPicklerUnpicklerObjectTests.test_reusing_unpickler_objectsc          
   C   sä   xÞt D ]Ö}| j|dÀ dd„ tdƒD ƒdtg }|ƒ }| j||d}| |¡ | ¡ }d}||| ƒ}|  |¡}xPt|ƒD ]D}	| ¡ r| 	¡ }
|  
| ¡ |¡ | ¡ r||  
| 	¡ |
t|ƒ ¡ q|W |  t|j¡ W d Q R X qW d S )N)r#  c             S   s   g | ]}|t |ƒf‘qS r   )r@   )r  rA   r   r   r   r  ‘  s    zSAbstractPicklerUnpicklerObjectTests._check_multiple_unpicklings.<locals>.<listcomp>iÐ  s   abcde)rè  rS   )r!  rf   rŠ   r/  rb  rê  r,  rj  r!   r%   r_   rA  rg   r  )r   Zioclassr#  rn  r  rç  r´   rë  rl  rB  rß  r   r   r   Ú_check_multiple_unpicklingsŽ  s"    


z?AbstractPicklerUnpicklerObjectTests._check_multiple_unpicklingsc             C   s   |   tj¡ d S )N)rp  r"   ré  )r   r   r   r   Ú"test_multiple_unpicklings_seekable¢  s    zFAbstractPicklerUnpicklerObjectTests.test_multiple_unpicklings_seekablec             C   s   |   t¡ d S )N)rp  r   )r   r   r   r   Ú$test_multiple_unpicklings_unseekable¥  s    zHAbstractPicklerUnpicklerObjectTests.test_multiple_unpicklings_unseekablec             C   s€   t tdƒƒ}xntD ]f}x`tddƒD ]R}tjt ¡ |d}| j||d}| |¡ | d¡ |  	|¡}|  
| ¡ |¡ q"W qW d S )Nr¡  r   é   )Úbuffer_size)rè  r   )r‹   rŠ   r!  r"   ÚBufferedRandomré  rb  rê  r$   rj  r_   rA  )r   re   r#  Zbuf_sizer  rç  rl  r   r   r   Ú"test_unpickling_buffering_readline¨  s    



zFAbstractPicklerUnpicklerObjectTests.test_unpickling_buffering_readline)r&   r'   r(   rb  rj  r   re  ri  rm  ro  rp  rq  rr  rv  r   r   r   r   r_    s    r_  Zreduce_Ac               @   s   e Zd Zdd„ ZdS )rh  c             C   s
   t tffS )N)r@   ri  )r   r   r   r   r=   »  s    zAAA.__reduce__N)r&   r'   r(   r=   r   r   r   r   rh  º  s   rh  c               @   s   e Zd ZdS )ÚBBBN)r&   r'   r(   r   r   r   r   rw  ¾  s   rw  c               @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚAbstractDispatchTableTestsc          	   C   sD   t  ¡ }|  |d¡}|  t¡ |j W d Q R X |  t|dƒ¡ d S )Nr   Údispatch_table)r"   ré  rb  rg   r  ry  r˜  ra   )r   r  r¾   r   r   r   Útest_default_dispatch_tableÃ  s
    z6AbstractDispatchTableTests.test_default_dispatch_tablec                s@   ˆ  ¡ ‰G ‡fdd„dˆjƒ‰ d‡ ‡‡fdd„	}ˆ |ˆ¡ d S )Nc                   s   e Zd Z” ZdS )zGAbstractDispatchTableTests.test_class_dispatch_table.<locals>.MyPicklerN)r&   r'   r(   ry  r   )Údtr   r   Ú	MyPicklerÏ  s   r|  c                s2   t  ¡ }ˆ ||ƒ}ˆ |jˆ¡ | | ¡ | ¡ S )N)r"   ré  r_   ry  rê  r,  )rc   rè  r  r¾   )r|  r{  r   r   r   r"  Ò  s
    

zCAbstractDispatchTableTests.test_class_dispatch_table.<locals>.dumps)N)Úget_dispatch_tablerb  Ú_test_dispatch_table)r   r"  r   )r|  r{  r   r   Útest_class_dispatch_tableË  s    z4AbstractDispatchTableTests.test_class_dispatch_tablec                s(   ˆ  ¡ ‰ d‡ ‡fdd„	}ˆ |ˆ ¡ d S )Nc                s:   t  ¡ }ˆ ||¡}ˆ |_ˆ |jˆ ¡ | | ¡ | ¡ S )N)r"   ré  rb  ry  r_   rê  r,  )rc   rè  r  r¾   )r{  r   r   r   r"  ß  s    
zFAbstractDispatchTableTests.test_instance_dispatch_table.<locals>.dumps)N)r}  r~  )r   r"  r   )r{  r   r   Útest_instance_dispatch_tableÛ  s    z7AbstractDispatchTableTests.test_instance_dispatch_tablec       
         sf  ‡fdd„}dd„ }d}|   ||ƒ|¡ |   ||ƒ|¡ d‰ ‡ fdd„}||t< |   ||ƒˆ ¡ |   ||ƒ|¡ tƒ }tƒ }|   ||ƒt¡ |  ||ƒt¡ |   ||ƒt¡ |  ||ƒt¡ ||t< |   ||ƒt¡ |   ||ƒˆ ¡ |   ||ƒt¡ |  ||ƒt¡ d	‰‡fd
d„}	|	|t< |t= |   ||ƒˆ¡ |  ||ƒt¡ |   ||ƒt¡ |  ||ƒt¡ d S )Nc                s   t  ˆ | dƒ¡S )Nr   )r   rh   )rc   )r"  r   r   Úcustom_load_dumpê  s    zIAbstractDispatchTableTests._test_dispatch_table.<locals>.custom_load_dumpc             S   s   t  t  | d¡¡S )Nr   )r   rh   r"  )rc   r   r   r   Údefault_load_dumpí  s    zJAbstractDispatchTableTests._test_dispatch_table.<locals>.default_load_dumpy      ð?       @Úreduce_1c                s
   t ˆ ffS )N)r@   )rc   )ÚREDUCE_1r   r   rƒ  ø  s    zAAbstractDispatchTableTests._test_dispatch_table.<locals>.reduce_1Úreduce_2c                s
   t ˆ ffS )N)r@   )rc   )ÚREDUCE_2r   r   r…    s    zAAbstractDispatchTableTests._test_dispatch_table.<locals>.reduce_2)r_   Úcomplexrh  rw  ri  r.  )
r   r"  ry  r  r‚  rå  rƒ  rC   rD   r…  r   )r„  r†  r"  r   r~  é  s:    z/AbstractDispatchTableTests._test_dispatch_tableN)r&   r'   r(   rz  r  r€  r~  r   r   r   r   rx  Á  s   rx  )r(  zDATA{0} = (ró  z	    {0!r}ú)z# Disassembly of DATA{0}zDATA{0}_DIS = """\z""")¯rÍ   r*   rË   r"   rÉ   r  r   r   r  r   r  r  Zunittestr  Útextwrapr   Zhttp.cookiesr   Ztestr   Ztest.supportr   r   r   r   r	   r
   r   r   r   r   Z
skipUnlessr]  r  rŠ   r9  r!  r   r   ré  r   r)   r2   r6   r8   r“   r:   r;   r>   r'   ra  r?   rB   rH   rE   rF   rG   rJ   rq   r*  rs   r+  ru   Z	DATA2_DISrw   Z	DATA3_DISry   Z	DATA4_DISr‡   r‰   rŒ   rÇ  ÚArithmeticErrorÚAssertionErrorr  ri   ÚBufferErrorÚBytesWarningÚDeprecationWarningr  ÚEnvironmentErrorr   ÚFloatingPointErrorÚFutureWarningÚGeneratorExitÚIOErrorÚImportErrorÚImportWarningÚIndentationErrorÚ
IndexErrorr®   ÚKeyboardInterruptÚLookupErrorÚMemoryErrorÚ	NameErrorr   ÚOSErrorr©   ÚPendingDeprecationWarningÚReferenceErrorr¾  ÚRuntimeWarningÚStopIterationÚSyntaxErrorÚSyntaxWarningÚSystemErrorÚ
SystemExitÚTabErrorr•  ÚUnboundLocalErrorÚUnicodeErrorÚUnicodeWarningÚUserWarningr‚   ÚWarningÚZeroDivisionErrorrŽ   r   r‘   rZ   ZTestCaser[   r  r!  r±  r´  r·  r¹  r»  rÎ  rÒ  rŽ  Úfloatr1  r‡  r2  r@   r3  r4  r2  rQ  r‹   r;  rK   r=  rˆ   rT  rN  rV  rˆ  r¯  r“  r«  r­  r½  r:  rO  rZ  r_  ri  rh  rw  rx  r&   r(  rA   rB  r"  r¾   rk   r^   r/  Újrš   rD   r   r   r   r   Ú<module>   s`  ,		cMDDL    G         F B( X
