
    <e~U                     N   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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j                     dS dS )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dS )AbstractMemoryTests   abcdefc                     | j         S N)source_bytesselfs    +/usr/lib/python3.11/test/test_memoryview.py_sourcezAbstractMemoryTests._source   s          c                 :    t          d | j        | j        g          S r   )filterro_typerw_typer
   s    r   _typeszAbstractMemoryTests._types   s    dT\4<8999r   c                     || j                   }t          j        |          }|                     |          |                     d         t          d                     |                     d         t                     |                     d         t          d                     |                     d         t          d                     |                     d         t          d                     |                     t          fd           |                     t          fd           |                     t          fd	           |                     t          fd
           |                     t          fd           |                     t          fd           |                     t          fd           d |                     t          j        |          |           d S )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>/       QsV r   c                       d         S )Nar   r   s   r   r   z=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>0   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   s   Bt|oa((JJqMM1s4yy)))adC(((1s4yy)))2D		***2D		****llll333*mmmm444*&<&<&<&<===*&=&=&=&=>>>)____555)^^^^444)^^^^444++[99999r   c                 D    | j         D ]}|                     |           d S r   )r   r8   )r   r5   s     r   test_getitemz AbstractMemoryTests.test_getitem4   s4    + 	- 	-B((,,,,	- 	-r   c           
          | j         D ]p} || j                  }|                     |          |                     t	                    fdt          t                              D                        qd S )Nc                      g | ]
}|         S r   r   ).0ir   s     r   
<listcomp>z1AbstractMemoryTests.test_iter.<locals>.<listcomp><   s    &C&C&Cqt&C&C&Cr   )r   r   r-   r.   listrangelenr   r5   r6   r   s      @r   	test_iterzAbstractMemoryTests.test_iter8   s    + 	E 	EB4<  A

1AT!WW&C&C&C&CU3q66]]&C&C&CDDDD	E 	Er   c                    | j         s|                     d           |                      | j                  }t          j        |          }|                     |          fd}|                     t          |d           |                     t          |d           |                     t          |t          d                     d | 	                    t          j        |          |           d S )Nno read-only type to testc                     | d<   d S )Nr   r   )valuer   s    r   setitemz:AbstractMemoryTests.test_setitem_readonly.<locals>.setitemD   s    AaDDDr   r   A   )
r   skipTestr   r#   r,   r-   r2   r4   
memoryviewr.   )r   r6   r7   rI   r   s       @r   test_setitem_readonlyz)AbstractMemoryTests.test_setitem_readonly>   s    | 	7MM5666LL&&oa((JJqMM	 	 	 	 	)Wd333)Wb111)Wj.>.>???++[99999r   c           
         | j         s|                     d           | j         |                      | j                  }t          j        |          }|                     |          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           fd}|                     t          |dd           |                     t          |dd           |                     t          |t          j
        d           |                     t          |t          j
         d           |                     t          |dd           |                     t          |dd           |                     t          |t          ddd          dfd           |                     t          |dt          ddd          fd           |                     t          |dd           |                     t          |dd           t          ddd          t          ddd          f}|                     t          ||d           j        dk    rt          nt          }|                     ||dd           |                     ||dd           |                     t          |t          dd          d           |                     t          |t          dd          d           d |                     t          j        |          |           d S )Nno writable type to test   1r   s   1bcdef   0   s   0bcdefs   12   s   012defr   r      r   s   cdedefs   ababcfc                 $     |          | <   d S r   r   )keyrH   r   r5   s     r   rI   z:AbstractMemoryTests.test_setitem_writable.<locals>.setiteme   s    RYYAcFFFr   r   r   r    r(   )r   r+   cs   ab)r   rK   r   r#   r,   r-   r/   _check_contentsr2   r3   r$   r4   sliceNotImplementedErrorformat
ValueErrorr.   )r   r6   r7   rI   slicesexcr   r5   s         @@r   test_setitem_writablez)AbstractMemoryTests.test_setitem_writableL   s   | 	6MM4555\LL&&oa((JJqMM4yy!RI...D!A#RI...E!A#RI...C!A#RI...r)}}!!!RI... 1Q3!A#RI...r)}}!!!1Q3!A#RI...	 	 	 	 	 	 	*gq$777*gr4888*gs{DAAA*g|TBBB)Wc4888)WdD999)WuQq||Q.?FFF)Wq%!A,,.?FFF)WdD999)Wc4888!A,,a!--wEEEHOOjj#w3///#w5111*guQqzz4@@@*guQqzz4@@@++[99999r   c                 <   | j         D ]} || j                  }|                     |          }|                     t                    5  |d= d d d            n# 1 swxY w Y   |                     t                    5  |dd= d d d            n# 1 swxY w Y   d S )NrR      )r   r   r-   r2   r4   rC   s       r   test_delitemz AbstractMemoryTests.test_delitem   s"   + 	 	B4<  A

1A""9--  aD              ""9--  acF              	 	s$   	AA	 A	>BB	B	c                 .     j         D ]}                      | j                            }|                                }d                     fddD                       }                     ||                                |t                     d S )Nr   c              3   ^   K   | ]'}                     t          |g                    V  (d S r   )getitem_typebytes)r=   rW   r   s     r   	<genexpr>z3AbstractMemoryTests.test_tobytes.<locals>.<genexpr>   sR        B  B23!!%**-- B  B  B  B  B  Br   r   )r   r-   r   tobytesjoinr.   r0   rf   )r   r5   r   r6   expecteds   `    r   test_tobytesz AbstractMemoryTests.test_tobytes   s    + 	, 	,B

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

22dl++,,A

AQY0000	1 	1r   c                    | j         D ]g}|                      || j                            | j         D ]}|                      |d          k               |                      |d          k               |                      |d          k               |                      |d          k               |                      |d          k               |                      |d          k               |                     k               |                     d d          k               |                     dd         d d          k               |                     dd         k               |                     dk               |                     dk               |                     dk               |                     dk               dfD ]~|                     t          fd           |                     t          fd	           |                     t          fd
           |                     t          fd           id S )Nr   s   abcdes   abcde1r   r   r   abcdefc                       k     S r   r   rW   r   s   r   r   z2AbstractMemoryTests.test_compare.<locals>.<lambda>       QU r   c                       k    S r   r   rs   s   r   r   z2AbstractMemoryTests.test_compare.<locals>.<lambda>       Q!V r   c                       k    S r   r   rs   s   r   r   z2AbstractMemoryTests.test_compare.<locals>.<lambda>   rv   r   c                       k    S r   r   rs   s   r   r   z2AbstractMemoryTests.test_compare.<locals>.<lambda>   rt   r   )r   r-   r   
assertTrueassertFalser2   r4   )r   r5   tp_comprW   r   s      @@r   test_comparez AbstractMemoryTests.test_compare   s    + 	< 	<B

22dl++,,A; 9 9WWY%7%7 7888  ggi&8&8!8999  ggh&7&7!7888WWX%6%6 6777  ggi&8&8!8999WWY%7%7 78888OOAF###OOA111I&&&OOAacFadN+++QqsVq[))) Q(]+++OOAM***X]+++OOHM*** ^ < <!!)]]]]];;;!!)^^^^^<<<!!)^^^^^<<<!!)]]]]];;;;	<+	< 	<r   c                    |                       || j                            }|                     |j        | j                   |                     |j        | j                   |                     |j        d           |                     |j        d           |                     t          |          d           |                     |j        | j        f           |                     |j	        d           |S )NrR   )r   r   r   )
r-   r   r.   r[   itemsizendimshaperB   strides
suboffsets)r   r5   r   s      r   check_attributes_with_typez.AbstractMemoryTests.check_attributes_with_type   s    JJrr$,''((4;///T]333###$'''Q###T]$4555r***r   c                     | j         s|                     d           |                     | j                   }|                     |j        d           d S )NrF   T)r   rK   r   r.   readonlyr   r   s     r   test_attributes_readonlyz,AbstractMemoryTests.test_attributes_readonly   sR    | 	7MM5666++DL99T*****r   c                     | j         s|                     d           |                     | j                   }|                     |j        d           d S )NrO   F)r   rK   r   r.   r   r   s     r   test_attributes_writablez,AbstractMemoryTests.test_attributes_writable   sR    | 	6MM4555++DL99U+++++r   c                    | j         D ]} || j                  }t          j        |          }|                     |          }t          j        |          }t          |d          }|                     |||                    d                     |                     t          j        |          |           d }|                     t          j        |          |           d S )Nzutf-8)	r   r   r#   r,   r-   strrX   encoder.   )r   r5   r6   r7   r   oldviewrefcountss          r   test_getbufferz"AbstractMemoryTests.test_getbuffer   s    + 		> 		>B4<  A/!,,K

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

1A

AACACQBAAJLLLOOBBDDDL""$$/// rr&zz""A

AACACQBLAJLLLOOBBDDDL""$$////G#	0 #	0r   c                 r   |                      t          d          }|5  t          |           d d d            n# 1 swxY w Y   |5  |                                 d d d            n# 1 swxY w Y   |5  |                                 d d d            n# 1 swxY w Y   |5  |d          d d d            n# 1 swxY w Y   |5  d|d<   d d d            n# 1 swxY w Y   |5  t          |           d d d            n# 1 swxY w Y   |5  |j         d d d            n# 1 swxY w Y   |5  |j         d d d            n# 1 swxY w Y   |5  |j         d d d            n# 1 swxY w Y   |5  |j	         d d d            n# 1 swxY w Y   |5  |j
         d d d            n# 1 swxY w Y   |5  |j         d d d            n# 1 swxY w Y   |5  |5  	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     dt          |                     |                     dt          |                     |                     ||           |                     |t#           || j                                       |                     | || j                             d S )Nreleasedr      xzreleased memory)assertRaisesRegexr\   rf   rh   rm   rB   r[   r~   r   r   r   r   assertInr   reprr.   assertNotEqualrL   r   )r   r   r5   checks       r   _check_releasedz#AbstractMemoryTests._check_released  s|   &&z:>>E!HHHAIIKKKAHHJJJAaDD4AaDCFFFAHHAJJAFFAJJAGGAII 	 	                	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	'Q000'a111AAz""T\*:*:;;<<<Arr$,//00000s	  :>>A((A,/A,5BBB#	B88B<?B<CCC$D  DDD!!D%(D%.EE	EE##E'*E'0FFFF%%F),F)2GG
G
G;G$G;$G(	(G;+G(	,G;;G?G?c                 v   | j         D ]} || j                  }|                     |          }|5 }|                     ||           d d d            n# 1 swxY w Y   |                     ||           |                     |          }|5  |                                 d d d            n# 1 swxY w Y   d S r   )r   r   r-   assertIsr   release)r   r5   r6   r   cms        r   test_contextmanagerz'AbstractMemoryTests.test_contextmanager  s7   + 		 		B4<  A

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

1A  		              		 		s#   AA	A	B--B1	4B1	c                    | j         D ]{} || j                  }|                     |          }|                                 |                     ||           |                                 |                     ||           |d S r   )r   r   r-   r   r   rC   s       r   test_releasez AbstractMemoryTests.test_release%  s    + 	( 	(B4<  A

1AIIKKK  B'''IIKKK  B''''	( 	(r   c                     | j         }||                     d            || j                  }|                     |          }t	          j        d          }|                     t          |j        |           d S )NrF   s   ZZZZ)	r   rK   r   r-   ioBytesIOr2   r4   readinto)r   r5   r6   r   r>   s        r   test_writable_readonlyz*AbstractMemoryTests.test_writable_readonly/  sr     \:MM5666Bt|JJqMMJw)QZ33333r   c                 H    |                      t          | j        i            d S r   )r2   r4   r-   r
   s    r   test_getbuf_failz$AbstractMemoryTests.test_getbuf_fail:  s"    )TZ44444r   c                    | j         }||                     d            || j                  }|                     |          }|                     t          |          t          d                     |                                 |                     t          |          t          d                     |                     |          }|                                 |                     t          t
          |           d S )NrF   r   )	r   rK   r   r-   r.   hashr   r2   r\   rC   s       r   	test_hashzAbstractMemoryTests.test_hash=  s     \:MM5666Bt|JJqMMa$y//222			a$y//222 JJqMM			*dA.....r   c                     | j         }||                     d            || j                  }|                     |          }|                     t
          t          |           d S )NrO   )r   rK   r   r-   r2   r\   r   rC   s       r   test_hash_writablez&AbstractMemoryTests.test_hash_writableO  s_    \:MM4555Bt|JJqMM*dA.....r   c                    | j         D ]} || j                  }|                     |          }g |ffd	}t          j        ||          }|                      |            |           ~t          j                                         |                      |            d            |                     d         |           d S )Nc                 2                         |           d S 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_weakrefX  s    + 	# 	#B4<  A

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

1A(188::..//FT(1++..777T(1++..QtttW>>>>	? 	?r   c                    | j         D ]} || j                  }|                     |          }|                                }|                     |j                   |                     t          |          j                   |                     |                                |                                           |	                                 |                                 d S r   )
r   r   r-   
toreadonlyry   r   rL   r.   rm   r   )r   r5   r6   r   mms        r   test_toreadonlyz#AbstractMemoryTests.test_toreadonlyo  s    + 	 	B4<  A

1ABOOBK(((OOJrNN3444RYY[[!((**555JJLLLHHJJJJ	 	r   c                    t          j         dg d          }t          |          }|                    d          }|                    d          }|dd         }t          |          }~|                     |d         d           |                     |d         d           |                     |j        d           |                     |j        d           |                    d          }|                     |d         d           |                     |d         d           |                     |j        d           |                     |j        d           d S )NH)   r   r   r   Br   rT   r   I)arrayrL   castr.   r[   )r   r+   r   r   r6   rW   d_s           r   test_issue22668z#AbstractMemoryTests.test_issue22668z  s;   K11122qMMFF3KKFF3KKacFqMM1s###1s###3'''3'''FF3KK1s###1s###3'''3'''''r   N) r   r   r   r	   propertyr   r   r8   r:   rD   rM   r_   rb   rk   ro   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s       L! ! X! : : X:: : :*- - -E E E: : :2: 2: 2:h  , , ,1 1 1< < <<	 	 	+ + +, , ,> > >$0 $0 $0L1 1 10
 
 
( ( (	4 	4 	45 5 5/ / /$/ / /# # #? ? ?	 	 	( ( ( ( (r   r   c                   "    e Zd ZeZeZeZdZdZ	dS )BaseBytesMemoryTestsrR   r   N)
r   r   r   rf   r   	bytearrayr   re   r~   r[   r   r   r   r   r     s'        GGLHFFFr   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dS )	BaseArrayMemoryTestsNc                 F    t          j         dt          |                    S Nr>   )r   r@   r   r6   s     r   r   zBaseArrayMemoryTests.<lambda>  s    ek#tAww77 r   c                 j    t          j         dt          |                                                    S r   )r   r@   rh   r   s     r   r   zBaseArrayMemoryTests.<lambda>  s$    5;sDGG#<#<#D#D#F#F r   r>   z/XXX test should be adapted for non-byte buffersc                     d S r   r   r
   s    r   r   z#BaseArrayMemoryTests.test_getbuffer      r   z:XXX NotImplementedError: tolist() only supports byte viewsc                     d S r   r   r
   s    r   ro   z BaseArrayMemoryTests.test_tolist  r   r   )r   r   r   r   r   re   r   r~   r[   unittestskipr   ro   r   r   r   r   r     s        G77GFFLu{3(HFX]DEE  FE X]OPP  QP  r   r   c                       e Zd Zd Zd ZdS )BaseMemoryviewTestsc                      t          |          S r   rL   )r   objs     r   r-   zBaseMemoryviewTests._view  s    #r   c                 D    |                      | ||                     d S r   r.   r   r5   r   contentss       r   rX   z#BaseMemoryviewTests._check_contents  s&    bbll+++++r   N)r   r   r   r-   rX   r   r   r   r   r     s2          , , , , ,r   r   c                   $    e Zd ZdZd Zd Zd ZdS )BaseMemorySliceTests   XabcdefYc                 4    t          |          }|dd         S NrR      r   r   r   r   s      r   r-   zBaseMemorySliceTests._view  s    sOO1vr   c                 T    |                      |dd          ||                     d S r   r   r   s       r   rX   z$BaseMemorySliceTests._check_contents  .    QqS22h<<00000r   c                     | j         D ]e}t           || j                            }t          j        |          }|dd          |                     t          j        |          |           fd S )NrR   rT   )r   rL   r   r#   r,   r.   )r   r5   r   r7   s       r   	test_refszBaseMemorySliceTests.test_refs  su    + 	> 	>B22dl++,,A/!,,KacFFS_Q//====		> 	>r   N)r   r   r   r	   r-   rX   r  r   r   r   r   r     sF        L  1 1 1> > > > >r   r   c                       e Zd ZdZd Zd ZdS )BaseMemorySliceSliceTestsr   c                 D    t          |          }|d d         dd          S )Nr  rR   r   r  s      r   r-   zBaseMemorySliceSliceTests._view  s#    sOO!uQRRyr   c                 T    |                      |dd          ||                     d S r   r   r   s       r   rX   z)BaseMemorySliceSliceTests._check_contents  r  r   N)r   r   r   r	   r-   rX   r   r   r   r  r    s7        L  1 1 1 1 1r   r  c                       e Zd Zd ZdS )BytesMemoryviewTestc                    | j         D ]} || j                  }|                     t          |                     |                     t          |                     |                     t
          t                     |                     t
          t          ||           |                     t
          t          |           |                     t
          t          |d           d S )N)object)argumentT)r   r   ry   rL   r2   r4   )r   r5   obs      r   test_constructorz$BytesMemoryviewTest.test_constructor  s    + 	H 	HBDL!!BOOJrNN+++OOJb111222i444iR<<<ibAAAiR$GGGG	H 	Hr   N)r   r   r   r  r   r   r   r  r    s(        H H H H Hr   r  c                       e Zd Zd ZdS )ArrayMemoryviewTestc                     t          j         dt          d                    }t          |          }t          j         dt          ddd                    }||d d <   |                     ||           d S )Nr>   
   	   r   )r   rA   rL   r.   )r   r+   r   new_as       r   test_array_assignz%ArrayMemoryviewTest.test_array_assign  sj    KU2YY''qMMCq"b!1!122!!!E"""""r   N)r   r   r   r  r   r   r   r  r    s#        # # # # #r   r  c                       e Zd ZdS )BytesMemorySliceTestNr   r   r   r   r  r            Dr   r  c                       e Zd ZdS )ArrayMemorySliceTestNr   r   r   r   r  r    r  r   r  c                       e Zd ZdS )BytesMemorySliceSliceTestNr   r   r   r   r  r    r  r   r  c                       e Zd ZdS )ArrayMemorySliceSliceTestNr   r   r   r   r!  r!    r  r   r!  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )	OtherTestc                    t          j        d          }t          |                    d                    }|                                }t	          |                              d          }|d d         |d d<   |dd          |dd <   |                     |j        d           dD ]}|                     |          5  |                                }t	          |                              |          }t	          |                              |          d d         |d d<   t	          |                              |          dd          |dd <   |                     |j        d           d d d            n# 1 swxY w Y   d S )Nctypesg333333?r   rT   Bbc)	r   import_modulerf   c_doublerL   r   r.   rH   subTest)r   r%  p6r   r   r[   s         r   test_ctypes_castzOtherTest.test_ctypes_cast  s   ,X666??3''((OOqMMs##2A2"1"122!""#&&& 	/ 	/Ff%% / /OO%%qMM&&v.."2++F33BQB7"1""2++F33ABB7!""  #.../ / / / / / / / / / / / / / /	/ 	/s   ?B0E;;E?	E?	c                     ddz  }t          |          }|d d d         }|                     |                                ddz             d S )NrQ   i@ r   30)rL   r.   hex)r   r   m1m2s       r   test_memoryview_hexzOtherTest.test_memoryview_hex  sM    6M]]"X4&=11111r   c                     t          d          }|                     t                    5  t          j        |           d d d            d S # 1 swxY w Y   d S )Nr   )rL   r2   r4   copyr   s     r   	test_copyzOtherTest.test_copy  s    vy)) 	 	IaLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAAc                     t          d          }t          t          j        dz             D ]I}|                     t
                    5  t          j        ||           d d d            n# 1 swxY w Y   Jd S )Nr   rR   )rL   rA   pickleHIGHEST_PROTOCOLr2   r4   dumps)r   r   protos      r   test_picklezOtherTest.test_pickle  s    v62Q677 	' 	'E""9-- ' 'Q&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' '	' 	's   A**A.	1A.	c                    dfd G fdd          } G fdd          } G fdd          }d t          t          d	z                      |                     t                    5   |                      d d d            n# 1 swxY w Y   d t          t          d	z                      |                     t          d  |                               d
gdz             d t          t          d	z                      |                     t           |            d                   d
gdz             d t          t          d	z                                          dd          |                     t          d          5   |            df          d d d            n# 1 swxY w Y   d t          t          d	z                                          dd          |                     t          d          5  d |            f          d d d            n# 1 swxY w Y   d t          t          d	z                      |                     t          d          5  d |            <   d d d            n# 1 swxY w Y   |                     d d         d           d t          t          d	z                      |                     t          d          5  dd  |            <   d d d            n# 1 swxY w Y   |                     d d         d           d t          t          d	z                      |                     t          d          5  d |            d<   d d d            n# 1 swxY w Y   |                     d d         d           d t          t          d	z                                          dd          |                     t          d          5  d |            df<   d d d            n# 1 swxY w Y   |                     dd         d           d t          t          d	z                                          dd          |                     t          d          5  dd |            f<   d d d            n# 1 swxY w Y   |                     d d         d           d t          t          d	z                      |                     t          d          5   |            d<   d d d            n# 1 swxY w Y   |                     d d         d           dD ]}|                     |          5  d t          t          d	z                                          |          |                     t          d          5   |            d<   d d d            n# 1 swxY w Y   |                     d d         d           d d d            n# 1 swxY w Y   dD ]}|                     |          5  d t          t          d	z                                          |          |                     t          d          5   |            d<   d d d            n# 1 swxY w Y   |                     d d         d           d d d            n# 1 swxY w Y   d t          t          d	z                                          d          |                     t          d          5   |            d<   d d d            n# 1 swxY w Y   |                     d d         d           d S )N   c                  N                                      t                     d S r   )r   r   )bar   sizes   r   r   z3OtherTest.test_use_released_memory.<locals>.release)  s    IIKKK4BBBr   c                       e Zd Z fdZdS )3OtherTest.test_use_released_memory.<locals>.MyIndexc                                   dS )Nra   r   r   r   s    r   	__index__z=OtherTest.test_use_released_memory.<locals>.MyIndex.__index__.  s    			qr   N)r   r   r   rD  r   s   r   MyIndexrA  -  s.              r   rF  c                       e Zd Z fdZdS )3OtherTest.test_use_released_memory.<locals>.MyFloatc                                   dS )Ng      @r   rC  s    r   	__float__z=OtherTest.test_use_released_memory.<locals>.MyFloat.__float__2      			tr   N)r   r   r   rJ  rE  s   r   MyFloatrH  1  .              r   rL  c                       e Zd Z fdZdS )2OtherTest.test_use_released_memory.<locals>.MyBoolc                                   dS )NTr   rC  s    r   __bool__z;OtherTest.test_use_released_memory.<locals>.MyBool.__bool__6  rK  r   N)r   r   r   rQ  rE  s   r   MyBoolrO  5  rM  r   rR        ra      r   )@   rT   zoperation forbiddenr   )rT   rV  *   s           s   spam   bhilqnBHILQN)fmtfd?)	rL   r   r2   r\   r.   r@   r   r   r)  )	r   rF  rL  rR  rZ  r>  r   r   r?  s	        @@@@r   test_use_released_memoryz"OtherTest.test_use_released_memory$  s#    	! 	! 	! 	! 	! 	! 	!	 	 	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	
 y..//z** 	 	ggiiLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 y..//a

m,,seai888y..//a		!n--uqy999y..//44S'BB##J0EFF 	 	ggiilOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 y..//44S'BB##J0EFF 	 	alOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 y..//##J0EFF 	 	AggiiL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	BQB)))y..//##J0EFF 	$ 	$#AjwwyyjM	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$BQB)))y..//##J0EFF 	% 	%$AggiikN	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%BQB)))y..//44S'BB##J0EFF 	! 	! AggiilO	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!AbD7+++y..//44S'BB##J0EFF 	! 	! AalO	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!BQB)))y..//##J0EFF 	 	799AaD	 	 	 	 	 	 	 	 	 	 	 	 	 	 	BQB)))! 	2 	2C#&& 2 2y6677<<SAA++J8MNN % %"799AaD% % % % % % % % % % % % % % %  BQB1112 2 2 2 2 2 2 2 2 2 2 2 2 2 2  	2 	2C#&& 2 2y6677<<SAA++J8MNN % %"799AaD% % % % % % % % % % % % % % %  BQB1112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y..//44S99##J0EFF 	 	688AaD	 	 	 	 	 	 	 	 	 	 	 	 	 	 	BQB)))))s"  6BBBF==GGH77H;>H;>JJJ=LL L>NN!NP//P36P3(SSS)UU
UAX%W0$X%0W44X%7W48!X%%X)	,X)	A[*Z5)[*5Z99[*<Z9=![**[.	1[.	]]#&]#N)r   r   r   r+  r1  r4  r:  r]  r   r   r   r#  r#    sd        / / /&2 2 2  
' ' 'd* d* d* d* d*r   r#  __main__)__doc__r   test.supportr   r#   r   r   r   r   r3  r6  r   r   r   r   r   r   r  TestCaser  r  r  r  r  r!  r#  r   mainr   r   r   <module>rc     s         



 				   				   & & & & & &y( y( y( y( y( y( y( y(@    .       .   (, , , , , , , ,> > > > > > > >"1 1 1 1 1 1 1 1H H H H H(+-H H H	# 	# 	# 	# 	#(+-	# 	# 	#	 	 	 	 	8,.	 	 		 	 	 	 	8,.	 	 		 	 	 	 	 13	 	 		 	 	 	 	 13	 	 	
J* J* J* J* J*! J* J* J*X zHMOOOOO r   