
    dafW                     L   d 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  G d d      Z G d de      Z G d d	e      Z G d
 d      Z G d d      Z G d d      Z G d dej&                  ee      Z G d dej&                  ee      Z G d dej&                  ee      Z G d dej&                  ee      Z G d dej&                  ee      Z G d dej&                  ee      Z G d dej&                        Zedk(  r ej8                          yy)zUnit tests for the memoryview

   Some tests are in test_bytes. Many tests that require _testbuffer.ndarray
   are in test_buffer.
    N)import_helperc                       e Zd ZdZed        Zed        Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)AbstractMemoryTests   abcdefc                     | j                   S N)source_bytesselfs    //root/Python-3.12.4/Lib/test/test_memoryview.py_sourcezAbstractMemoryTests._source   s           c                 F    t        d | j                  | j                  g      S r   )filterro_typerw_typer
   s    r   _typeszAbstractMemoryTests._types   s    dT\\4<<899r   c                 D    || j                         }t        j                  |      }| j                  |      | j	                  d   t        d             | j                  d   t               | j	                  d   t        d             | j	                  d   t        d             | j	                  d   t        d             | j                  t        fd       | j                  t        fd       | j                  t        fd	       | j                  t        fd
       | j                  t        fd       | j                  t        fd       | j                  t        fd       d | j	                  t        j                  |      |       y )Nr      a      fic                       d   S )N    ms   r   <lambda>z=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>*   s    ad r   c                       d   S )Nr   r   s   r   r   z=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>+   s    ae r   c                  *     t         j                     S r   sysmaxsizer   s   r   r   z=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>,   s    an r   c                  ,     t         j                      S r   r"   r   s   r   r   z=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>-   s    ao r   c                       d    S r   r   r   s   r   r   z=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>/   s    QtW r   c                       d   S )N        r   r   s   r   r   z=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>0       QsV r   c                       d   S )Nar   r   s   r   r   z=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>1   r)   r   )r   r#   getrefcount_viewassertEqualordassertIsInstanceintassertRaises
IndexError	TypeError)r   tpboldrefcountr   s       @r   check_getitem_with_typez+AbstractMemoryTests.check_getitem_with_type    s0   t||ooa(JJqM1s4y)adC(1s4y)2D	*2D	**l3*m4*&<=*&=>)_5)^4)^4+[9r   c                 H    | j                   D ]  }| j                  |        y r   )r   r8   )r   r5   s     r   test_getitemz AbstractMemoryTests.test_getitem5   s#    ++ 	-B((,	-r   c           	          | j                   D ]c  } || j                        }| j                  |      }| j                  t	        |      t        t        |            D cg c]  }||   	 c}       e y c c}w r   )r   r   r-   r.   listrangelenr   r5   r6   r   is        r   	test_iterzAbstractMemoryTests.test_iter9   sc    ++ 	EB4<< A

1AT!WU3q6]&Cqt&CD	E 'Ds   A4c                    | j                   s| j                  d       | j                  | j                        }t        j                  |      }| j                  |      fd}| j                  t        |d       | j                  t        |d       | j                  t        |t        d             d | j                  t        j                  |      |       y )Nno read-only type to testc                     | d<   y )Nr   r   )valuer   s    r   setitemz:AbstractMemoryTests.test_setitem_readonly.<locals>.setitemE   s    AaDr   r   A   )
r   skipTestr   r#   r,   r-   r2   r4   
memoryviewr.   )r   r6   r7   rF   r   s       @r   test_setitem_readonlyz)AbstractMemoryTests.test_setitem_readonly?   s    ||MM56LL&ooa(JJqM	)Wd3)Wb1)Wj.>?+[9r   c           
         | j                   s| j                  d       | j                   | j                  | j                        }t        j                  |      }| j                  |      t        d      d<   | j                  |d        d      dd | j                  |d        d      dd	 | j                  |d
        d      dd | j                  |d
        d      d d  | j                  |d       dd dd	 | j                  |d        d      d d  dd	 dd | j                  |d       fd}| j                  t        |dd       | j                  t        |dd       | j                  t        |t        j                  d       | j                  t        |t        j                   d       | j                  t        |dd       | j                  t        |dd       | j                  t        |t        ddd      dfd       | j                  t        |dt        ddd      fd       | j                  t        |dd       | j                  t        |dd       t        ddd      t        ddd      f}| j                  t        ||d       j                  dk(  rt        nt        }| j                  ||dd       | j                  ||dd       | j                  t        |t        dd      d       | j                  t        |t        dd      d       d | j!                  t        j                  |      |       y )Nno writable type to test   1r   s   1bcdef   0   s   0bcdefs   12   s   012defr   r      r   s   cdedefs   ababcfc                      |      | <   y r   r   )keyrE   r   r5   s     r   rF   z:AbstractMemoryTests.test_setitem_writable.<locals>.setitemf   s    YAcFr   r   r   r    r(   )r   r+   cs   ab)r   rH   r   r#   r,   r-   r/   _check_contentsr2   r3   r$   r4   sliceNotImplementedErrorformat
ValueErrorr.   )r   r6   r7   rF   slicesexcr   r5   s         @@r   test_setitem_writablez)AbstractMemoryTests.test_setitem_writableM   s   ||MM45\\LL&ooa(JJqM4y!RI.D!ARI.E!ARI.C!ARI.)}!RI. 1Q!ARI.)}!1Q!ARI.	 	*gq$7*gr48*gs{{DA*g|TB)Wc48)WdD9)WuQq|Q.?F)Wq%!A,.?F)WdD9)Wc48!A,a!--wEHHOj#w3/#w51*guQqz4@*guQqz4@+[9r   c                 $   | j                   D ]i  } || j                        }| j                  |      }| j                  t              5  |d= d d d        | j                  t              5  |dd= d d d        k y # 1 sw Y   /xY w# 1 sw Y   xY w)NrO      )r   r   r-   r2   r4   r   r5   r6   r   s       r   test_delitemz AbstractMemoryTests.test_delitem   s    ++ 	B4<< A

1A""9- aD""9- acF 	  s   A:)B:B	B	c                      j                   D ]u  } j                   | j                              }|j                         }dj	                   fddD              } j                  ||        j                  |t               w y )Nr   c              3   T   K   | ]  }j                  t        |g             ! y wr   )getitem_typebytes).0rT   r   s     r   	<genexpr>z3AbstractMemoryTests.test_tobytes.<locals>.<genexpr>   s)       B23!!%*- Bs   %(r   )r   r-   r   tobytesjoinr.   r0   rd   )r   r5   r   r6   expecteds   `    r   test_tobytesz AbstractMemoryTests.test_tobytes   sv    ++ 	,B

2dll+,A		Axx  B7@ B BHQ)!!!U+	,r   c                     | j                   D ]N  }| j                   || j                              }|j                         }| j	                  |t        d             P y )Nr   )r   r-   r   tolistr.   r<   )r   r5   r   ls       r   test_tolistzAbstractMemoryTests.test_tolist   sK    ++ 	1B

2dll+,A
AQY0	1r   c                    | j                   D ]  }| j                   || j                              | j                   D ]  }| j                   |d      k(         | j	                   |d      k7         | j	                   |d      k(         | j                   |d      k7         | j	                   |d      k(         | j                   |d      k7          | j                  k(         | j                  d d  k(         | j                  dd d d  k(         | j	                  dd k(         | j	                  dk(         | j                  dk7         | j	                  dk(         | j                  dk7         dfD ]j  | j                  t        fd       | j                  t        fd	       | j                  t        fd
       | j                  t        fd       l  y )Nr   s   abcdes   abcde1r   r   r   abcdefc                       k  S r   r   rT   r   s   r   r   z2AbstractMemoryTests.test_compare.<locals>.<lambda>       QU r   c                       k  S r   r   rr   s   r   r   z2AbstractMemoryTests.test_compare.<locals>.<lambda>       Q!V r   c                       k\  S r   r   rr   s   r   r   z2AbstractMemoryTests.test_compare.<locals>.<lambda>   ru   r   c                       kD  S r   r   rr   s   r   r   z2AbstractMemoryTests.test_compare.<locals>.<lambda>   rs   r   )r   r-   r   
assertTrueassertFalser2   r4   )r   r5   tp_comprT   r   s      @@r   test_comparez AbstractMemoryTests.test_compare   s    ++ 	<B

2dll+,A;; 9WY%7 78  gi&8!89  gh&7!78WX%6 67  gi&8!89WY%7 789 OOAF#OOA1I&OOAaFadN+QqVq[) Q(]+OOAM*X]+OOHM* ^ <!!)];!!)^<!!)^<!!)];	<+	<r   c                    | j                   || j                              }| j                  |j                  | j                         | j                  |j                  | j                         | j                  |j
                  d       | j                  |j                  d       | j                  t        |      d       | j                  |j                  | j                  f       | j                  |j                  d       |S )NrO   )r   r   r   )
r-   r   r.   rX   itemsizendimshaper>   strides
suboffsets)r   r5   r   s      r   check_attributes_with_typez.AbstractMemoryTests.check_attributes_with_type   s    JJr$,,'(4;;/T]]3#$'Q#T]]$45r*r   c                     | j                   s| j                  d       | j                  | j                         }| j                  |j                  d       y )NrC   T)r   rH   r   r.   readonlyr   r   s     r   test_attributes_readonlyz,AbstractMemoryTests.test_attributes_readonly   s>    ||MM56++DLL9T*r   c                     | j                   s| j                  d       | j                  | j                         }| j                  |j                  d       y )NrL   F)r   rH   r   r.   r   r   s     r   test_attributes_writablez,AbstractMemoryTests.test_attributes_writable   s>    ||MM45++DLL9U+r   c                    | j                   D ]  } || j                        }t        j                  |      }| j	                  |      }t        j                  |      }t        |d      }| j                  |||j                  d             | j                  t        j                  |      |       d }| j                  t        j                  |      |        y )Nzutf-8)	r   r   r#   r,   r-   strrU   encoder.   )r   r5   r6   r7   r   oldviewrefcountss          r   test_getbufferz"AbstractMemoryTests.test_getbuffer   s    ++ 		>B4<< A//!,K

1A!ooa0OAwA  Q(9:S__Q/AAS__Q/=		>r   c                 h   | j                   D ]"  }t        |t              s G d d      } G d d|      } G d d      } | |d            }| j                  |      } |       }||_        ||_        t        j                  |      }d x}x}}t        j                          | j                   |       d u  |               | |d            } |       }||_        ||_        t        j                  |      }d x}}t        j                          | j                   |       d u  |              % y )Nc                       e Zd Zd Zy)+AbstractMemoryTests.test_gc.<locals>.MyViewc                 $    t        |      | _        y r   )rI   r   )r   bases     r   __init__z4AbstractMemoryTests.test_gc.<locals>.MyView.__init__   s    '-DFr   N)__name__
__module____qualname__r   r   r   r   MyViewr      s    .r   r   c                       e Zd Zy)-AbstractMemoryTests.test_gc.<locals>.MySourceNr   r   r   r   r   r   MySourcer          r   r   c                       e Zd Zy)-AbstractMemoryTests.test_gc.<locals>.MyObjectNr   r   r   r   MyObjectr      r   r   r      abc)r   
isinstancetyper-   r   oweakrefrefgccollectrx   x)	r   r5   r   r   r   r6   r   r   wrs	            r   test_gczAbstractMemoryTests.test_gc   s
   ++ #	0Bb$'. .2  
 F$A

1A
AACACQBAAJJLOOBDDL"$/ r&z"A
AACACQBLAJJLOOBDDL"$/G#	0r   c                    | j                  t        d      }|5  t        |       d d d        |5  |j                          d d d        |5  |j	                          d d d        |5  |d    d d d        |5  d|d<   d d d        |5  t        |       d d d        |5  |j                   d d d        |5  |j                   d d d        |5  |j                   d d d        |5  |j                   d d d        |5  |j                   d d d        |5  |j                   d d d        |5  |5  	 d d d        d d d        | j                  dt        |             | j                  dt        |             | j                  ||       | j!                  |t#         || j$                                     | j!                  | || j$                               y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xxY w# 1 sw Y   nxY w# 1 sw Y   dxY w# 1 sw Y   ZxY w# 1 sw Y   PxY w# 1 sw Y   FxY w# 1 sw Y   DxY w# 1 sw Y   IxY w)Nreleasedr      xzreleased memory)assertRaisesRegexrY   rd   rg   rl   r>   rX   r}   r~   r   r   r   assertInr   reprr.   assertNotEqualrI   r   )r   r   r5   checks       r   _check_releasedz#AbstractMemoryTests._check_released  s   &&z:>E!HAIIKAHHJAaD4AaDCFAHHAJJAFFAJJAGGAII 	 	 	'Q0'a1AAz"T\\*:;<Ar$,,/0) 	 	 	s   GG
G*%G75HHH2H+	H8 I7II%I9(I,*I9GG'*G47HHHH(+H58IIII),I6	1I99Jc                 R   | j                   D ]  } || j                        }| j                  |      }|5 }| j                  ||       d d d        | j	                  ||       | j                  |      }|5  |j                          d d d         y # 1 sw Y   JxY w# 1 sw Y   xY wr   )r   r   r-   assertIsr   release)r   r5   r6   r   cms        r   test_contextmanagerz'AbstractMemoryTests.test_contextmanager  s    ++ 		B4<< A

1A %bb!$%  B'

1A 		 		% %
 s   B5BB	B&	c                     | j                   D ]i  } || j                        }| j                  |      }|j                          | j	                  ||       |j                          | j	                  ||       k y r   )r   r   r-   r   r   r_   s       r   test_releasez AbstractMemoryTests.test_release&  sb    ++ 	(B4<< A

1AIIK  B'IIK  B'	(r   c                     | j                   }|| j                  d        || j                        }| j                  |      }t	        j
                  d      }| j                  t        |j                  |       y )NrC   s   ZZZZ)	r   rH   r   r-   ioBytesIOr2   r4   readintor?   s        r   test_writable_readonlyz*AbstractMemoryTests.test_writable_readonly0  s^     \\:MM56t||JJqMJJw)QZZ3r   c                 F    | j                  t        | j                  i        y r   )r2   r4   r-   r
   s    r   test_getbuf_failz$AbstractMemoryTests.test_getbuf_fail;  s    )TZZ4r   c                    | j                   }|| j                  d        || j                        }| j                  |      }| j	                  t        |      t        d             |j                          | j	                  t        |      t        d             | j                  |      }|j                          | j                  t        t
        |       y )NrC   r   )	r   rH   r   r-   r.   hashr   r2   rY   r_   s       r   	test_hashzAbstractMemoryTests.test_hash>  s     \\:MM56t||JJqMa$y/2			a$y/2 JJqM			*dA.r   c                     | j                   }|| j                  d        || j                        }| j                  |      }| j	                  t
        t        |       y )NrL   )r   rH   r   r-   r2   rY   r   r_   s       r   test_hash_writablez&AbstractMemoryTests.test_hash_writableP  sJ    \\:MM45t||JJqM*dA.r   c                 p   | j                   D ]  } || j                        }| j                  |      }g |ffd	}t        j                  ||      }| j                   |       |       ~t        j                  j                          | j                   |       d        | j                  d   |        y )Nc                 (    j                  |       y r   )append)r   r6   Ls     r   callbackz2AbstractMemoryTests.test_weakref.<locals>.callback_  s    r   r   )	r   r   r-   r   r   r   testsupport
gc_collect)r   r5   r6   r   r   r   r   s         @r   test_weakrefz AbstractMemoryTests.test_weakrefY  s    ++ 	#B4<< A

1AA  Q)BMM"$"LL##%MM"$%MM!A$"	#r   c           
      ^   | j                   D ]  } || j                        }| j                  |      }t        t	        |j                                     }| j                  t        t	        |            |       | j                  t        t	        |            t        |d d d                 y )Nr   )r   r   r-   r<   reversedrl   r.   )r   r5   r6   r   aslists        r   test_reversedz!AbstractMemoryTests.test_reversedh  s    ++ 	?B4<< A

1A(188:./FT(1+.7T(1+.QttW>	?r   c                    | j                   D ]  } || j                        }| j                  |      }|j                         }| j	                  |j
                         | j	                  t        |      j
                         | j                  |j                         |j                                |j                          |j                           y r   )
r   r   r-   
toreadonlyrx   r   rI   r.   rl   r   )r   r5   r6   r   mms        r   test_toreadonlyz#AbstractMemoryTests.test_toreadonlyp  s    ++ 	B4<< A

1ABOOBKK(OOJrN334RYY[!((*5JJLHHJ	r   c                 Z   t        j                   dg d      }t        |      }|j                  d      }|j                  d      }|dd }t        |      }~| j                  |d   d       | j                  |d   d       | j                  |j                  d       | j                  |j                  d       |j                  d      }| j                  |d   d       | j                  |d   d       | j                  |j                  d       | j                  |j                  d       y )NH)   r   r   r   Br   rQ   r   I)arrayrI   castr.   rX   )r   r+   r   r   r6   rT   d_s           r   test_issue22668z#AbstractMemoryTests.test_issue22668{  s    KK12qMFF3KFF3KaFqM1s#1s#3'3'FF3K1s#1s#3'3'r   N) r   r   r   r	   propertyr   r   r8   r:   rA   rJ   r\   r`   rj   rn   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s    L! ! : ::*-E:2:h,1<<	+,>$0L10
(	45/$/#?	(r   r   c                        e Zd ZeZeZeZdZdZ	y)BaseBytesMemoryTestsrO   r   N)
r   r   r   rd   r   	bytearrayr   rc   r}   rX   r   r   r   r   r     s    GGLHFr   r   c                       e Zd ZdZd Zd Z ej                  d      j                  ZdZ e	j                  d      d        Z e	j                  d      d        Zy)	BaseArrayMemoryTestsNc                 @    t        j                   dt        |            S Nr@   )r   r<   r   r6   s     r   r   zBaseArrayMemoryTests.<lambda>  s    ekk#tAw7 r   c                 \    t        j                   dt        |            j                         S r   )r   r<   rg   r   s     r   r   zBaseArrayMemoryTests.<lambda>  s    5;;sDG#<#D#D#F r   r@   z/XXX test should be adapted for non-byte buffersc                      y r   r   r
   s    r   r   z#BaseArrayMemoryTests.test_getbuffer      r   z:XXX NotImplementedError: tolist() only supports byte viewsc                      y r   r   r
   s    r   rn   z BaseArrayMemoryTests.test_tolist  r   r   )r   r   r   r   r   rc   r   r}   rX   unittestskipr   rn   r   r   r   r   r     sl    G7GFLu{{3((HFX]]DE F X]]OP Qr   r   c                       e Zd Zd Zd Zy)BaseMemoryviewTestsc                     t        |      S r   rI   )r   objs     r   r-   zBaseMemoryviewTests._view  s    #r   c                 4    | j                  | ||             y r   r.   r   r5   r   contentss       r   rU   z#BaseMemoryviewTests._check_contents  s    bl+r   N)r   r   r   r-   rU   r   r   r   r   r     s    ,r   r   c                   "    e Zd ZdZd Zd Zd Zy)BaseMemorySliceTests   XabcdefYc                 "    t        |      }|dd S NrO      r   r   r   r   s      r   r-   zBaseMemorySliceTests._view  s    sO1vr   c                 :    | j                  |dd  ||             y r   r   r   s       r   rU   z$BaseMemorySliceTests._check_contents      Qq2h<0r   c                     | j                   D ]\  }t         || j                              }t        j                  |      }|dd  | j                  t        j                  |      |       ^ y )NrO   rQ   )r   rI   r   r#   r,   r.   )r   r5   r   r7   s       r   	test_refszBaseMemorySliceTests.test_refs  sX    ++ 	>B2dll+,A//!,KaFS__Q/=		>r   N)r   r   r   r	   r-   rU   r  r   r   r   r   r     s    L1>r   r   c                       e Zd ZdZd Zd Zy)BaseMemorySliceSliceTestsr   c                 (    t        |      }|d d dd  S )Nr   rO   r   r  s      r   r-   zBaseMemorySliceSliceTests._view  s    sO!uQRyr   c                 :    | j                  |dd  ||             y r   r   r   s       r   rU   z)BaseMemorySliceSliceTests._check_contents  r  r   N)r   r   r   r	   r-   rU   r   r   r   r  r    s    L1r   r  c                       e Zd Zd Zy)BytesMemoryviewTestc                    | j                   D ]  } || j                        }| j                  t        |             | j                  t        |             | j	                  t
        t               | j	                  t
        t        ||       | j	                  t
        t        |       | j	                  t
        t        |d        y )N)object)argumentT)r   r   rx   rI   r2   r4   )r   r5   obs      r   test_constructorz$BytesMemoryviewTest.test_constructor  s    ++ 	HBDLL!BOOJrN+OOJb12i4iR<ibAiR$G	Hr   N)r   r   r   r  r   r   r   r  r    s    Hr   r  c                       e Zd Zd Zy)ArrayMemoryviewTestc                     t        j                   dt        d            }t        |      }t        j                   dt        ddd            }||d d  | j                  ||       y )Nr@   
   	   r   )r   r=   rI   r.   )r   r+   r   new_as       r   test_array_assignz%ArrayMemoryviewTest.test_array_assign  sQ    KKU2Y'qMCq"b!12!E"r   N)r   r   r   r  r   r   r   r  r    s    #r   r  c                       e Zd Zy)BytesMemorySliceTestNr   r   r   r   r  r        r   r  c                       e Zd Zy)ArrayMemorySliceTestNr   r   r   r   r  r    r  r   r  c                       e Zd Zy)BytesMemorySliceSliceTestNr   r   r   r   r  r    r  r   r  c                       e Zd Zy)ArrayMemorySliceSliceTestNr   r   r   r   r   r     r  r   r   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)	OtherTestc                 t   t        j                  d      }t        |j                  d            }|j                         }t	        |      j                  d      }|d d |d d |dd  |dd  | j                  |j                  d       dD ]  }| j                  |      5  |j                         }t	        |      j                  |      }t	        |      j                  |      d d |d d t	        |      j                  |      dd  |dd  | j                  |j                  d       d d d         y # 1 sw Y   xY w)Nctypesg333333?r   rQ   Bbc)	r   import_modulerd   c_doublerI   r   r.   rE   subTest)r   r$  p6r   r   rX   s         r   test_ctypes_castzOtherTest.test_ctypes_cast   s&   ,,X66??3'(OOqMs#2A"112!"#& 	/Ff% /OO%qM&&v."2++F3BQ7"1"2++F3AB7!"  #./ /	// /s   BD..D7	c                 z   t        j                  dddd      }t        j                  dddd      }t        |      j                  d      }t        |      j                  d      }| j	                  |j
                  dz  |j
                         | j                  |j                         |j                                y )	Neeer(   g      g      ?fffefrQ   )structpackrI   r   r.   nbytesassertListEqualrl   )r   	half_data
float_data	half_view
float_views        r   test_half_floatzOtherTest.test_half_float  s    KKsD#6	[[T37
y)..s3	
+005
))A-z/@/@AY--/1B1B1DEr   c                 z    ddz  }t        |      }|d d d   }| j                  |j                         ddz         y )NrN   i@ r   30)rI   r.   hex)r   r   m1m2s       r   test_memoryview_hexzOtherTest.test_memoryview_hex  s;    6M]"X4&=1r   c                     t        d      }| j                  t              5  t        j                  |       d d d        y # 1 sw Y   y xY w)Nr   )rI   r2   r4   copyr   s     r   	test_copyzOtherTest.test_copy"  s:    vy) 	IIaL	 	 	s   A  A	c                     t        d      }t        t        j                  dz         D ]6  }| j	                  t
              5  t        j                  ||       d d d        8 y # 1 sw Y   CxY w)Nr   rO   )rI   r=   pickleHIGHEST_PROTOCOLr2   r4   dumps)r   r   protos      r   test_picklezOtherTest.test_pickle'  sa    v622Q67 	'E""9- 'Q&' '	'' 's    A""A+	c                    dfd G fdd      } G fdd      } G fdd      }d t        t        d	z              | j                  t              5   |           d d d        d t        t        d	z              | j	                  t        d  |              d
gdz         d t        t        d	z              | j	                  t         |       d       d
gdz         d t        t        d	z              j                  dd      | j                  t        d      5   |       df    d d d        d t        t        d	z              j                  dd      | j                  t        d      5  d |       f    d d d        d t        t        d	z              | j                  t        d      5  d |       <   d d d        | j	                  d d d       d t        t        d	z              | j                  t        d      5  dd  |        d d d        | j	                  d d d       d t        t        d	z              | j                  t        d      5  d |       d d d d        | j	                  d d d       d t        t        d	z              j                  dd      | j                  t        d      5  d |       df<   d d d        | j	                  dd d       d t        t        d	z              j                  dd      | j                  t        d      5  dd |       f<   d d d        | j	                  d d d       d t        t        d	z              | j                  t        d      5   |       d<   d d d        | j	                  d d d       dD ]  }| j                  |      5  d t        t        d	z              j                  |      | j                  t        d      5   |       d<   d d d        | j	                  d d d       d d d         dD ]  }| j                  |      5  d t        t        d	z              j                  |      | j                  t        d      5   |       d<   d d d        | j	                  d d d       d d d         d t        t        d	z              j                  d      | j                  t        d      5   |       d<   d d d        | j	                  d d d       y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   JxY w# 1 sw Y    xY w# 1 sw Y   xY w# 1 sw Y   HxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)N   c                  <    j                          t               y r   )r   r   )bar   sizes   r   r   z3OtherTest.test_use_released_memory.<locals>.release2  s    IIK4Br   c                       e Zd Z fdZy)3OtherTest.test_use_released_memory.<locals>.MyIndexc                              y)Nr^   r   r   r   s    r   	__index__z=OtherTest.test_use_released_memory.<locals>.MyIndex.__index__7  s    	r   N)r   r   r   rQ  r   s   r   MyIndexrN  6  s    r   rS  c                       e Zd Z fdZy)3OtherTest.test_use_released_memory.<locals>.MyFloatc                              y)Ng      @r   rP  s    r   	__float__z=OtherTest.test_use_released_memory.<locals>.MyFloat.__float__;      	r   N)r   r   r   rW  rR  s   r   MyFloatrU  :      r   rY  c                       e Zd Z fdZy)2OtherTest.test_use_released_memory.<locals>.MyBoolc                              y)NTr   rP  s    r   __bool__z;OtherTest.test_use_released_memory.<locals>.MyBool.__bool__?  rX  r   N)r   r   r   r^  rR  s   r   MyBoolr\  >  rZ  r   r_        r^      r   )@   rQ   zoperation forbiddenr   )rQ   rc  *   s           s   spam   bhilqnBHILQN)fmtfd?)	rI   r   r2   rY   r.   r<   r   r   r(  )	r   rS  rY  r_  rg  rK  r   r   rL  s	        @@@@r   test_use_released_memoryz"OtherTest.test_use_released_memory-  s    	!	 		 		 	
 y./z* 	giL	 y./a
m,seai8y./a	!n-uqy9y./44S'B##J0EF 	gilO	 y./44S'B##J0EF 	alO	 y./##J0EF 	AgiL	BQ)y./##J0EF 	$#AjwyM	$BQ)y./##J0EF 	%$AgiN	%BQ)y./44S'B##J0EF 	! AgilO	!Ab7+y./44S'B##J0EF 	! AalO	!BQ)y./##J0EF 	9AaD	BQ)! 	2C#& 2y67<<SA++J8MN %"9AaD%  BQ12 2	2  	2C#& 2y67<<SA++J8MN %"9AaD%  BQ12 2	2 y./44S9##J0EF 	8AaD	BQ)Y	 		 	
	 	
	 		$ 	$	% 	%	! 	!
	! 	!	 	% %2 2% %2 2	 	s    U 2UU
U'!U48VVV!V( ?WV5*W(?W'W2WW) U
UU$'U14U>VVV%(V25V?:WW	WWW&	)W2N)	r   r   r   r*  r8  r>  rA  rG  rj  r   r   r   r"  r"    s"    /&F2
'd*r   r"  __main__)__doc__r   test.supportr   r#   r   r   r   r   r@  rC  r0  r   r   r   r   r   r   r  TestCaser  r  r  r  r  r   r"  r   mainr   r   r   <module>rp     s3     
 	   	    &y( y(@. . (, ,> >"1 1H(++-H	#(++-	#	8,,.		8,,.		 1 13		 1 13	
R*!! R*h zHMMO r   