Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.11/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.11/test/__pycache__/test_mmap.cpython-311.opt-1.pyc

�

SԚgA���z�ddlmZmZmZmZmZmZddlmZddl	m
Z
mZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZed��ZejZde
j���d�Zdd	�Zerejd
���Gd�dej��ZGd
�dej��Zedkrej��dSdS)�)�requires�_2G�_4G�
gc_collect�cpython_only�
is_emscripten)�
import_module)�TESTFN�unlinkN�mmap�python_�
_test_mmap�
c��d�tjtj|�����}t
�d|��S)N�)�k�_)�join�random�choices�string�ascii_uppercase�tagname_prefix)�length�suffixs  �+/usr/local/lib/python3.11/test/test_mmap.py�random_tagnamers9��
�W�W�V�^�F�$:�f�E�E�E�
F�
F�F��'�'�v�'�'�'�z.incompatible with Emscripten's mmap emulation.c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejeed��d��d���Zd�Zd�Z d�Z!eje"j#dkd��d ���Z$e%eje"j#dkd��d!�����Z&eje"j#dkd��d"���Z'eje"j#dkd��d#���Z(d$�Z)d%�Z*d&�Z+d'�Z,d(�Z-d)�Z.d*�Z/d+�Z0ejeejd,��d-��d.���Z1eje"j#dkd��d/���Z2eje"j#dkd��d0���Z3eje"j#dkd��d1���Z4eje"j#dkd��d2���Z5d3�Z6d4S)5�	MmapTestsc��tj�t��rtjt��dSdS�N)�os�path�existsr
r��selfs r�setUpzMmapTests.setUp"s8��
�7�>�>�&�!�!�	��I�f������	�	rc�\�	tjt��dS#t$rYdSwxYwr")r#rr
�OSErrorr&s r�tearDownzMmapTests.tearDown&s?��	��I�f��������	�	�	��D�D�	���s��
+�+c��
�ttd��}	|�dtz��|�d��|�dtdz
z��|���t
�|���dtz��}|���n#|���wxYwtt|����}|�
|�d��t��|�
t|��dtz��|�
|dd��|�
|dd�d��|�
t|jt|����|�
t|jt|��d��d|d<d	|tdztdzdz�<|�
|dd��|�
|dd�d
��|�
|tdz
tdz�d
��|���t#jd|��}|�|�d��nV|�d��\}}||z
}|�
|t��|�
|tdz��|�dd��|�
|���d��|�dd��|�
|���d��|�dd��|�
|���t|����|�
t.|jd��|�
t.|jdd��|�
t.|jt|��dz
d��	|�d��|�
t|��d��|�
t.|jdd��ttd��}	|�dd��|�
|���d��|���n#|���wxYw|�
|���d��n#t4$rYnwxYw|���dS)Nzbw+��foo��rs�3�bars3��sfoobars	[A-Za-z]+zregex match on mmap failed!��*������rb)�openr
�write�PAGESIZE�flushr�fileno�close�str�type�assertEqual�find�len�assertRaises�
IndexError�__getitem__�__setitem__�re�search�fail�span�seek�tell�
ValueError�resize�size�SystemError)r'�f�m�tp�match�start�endrs        r�
test_basiczMmapTests.test_basic,s���
������	�
�G�G�E�8�O�$�$�$�
�G�G�F�O�O�O�
�G�G�E�H�Q�J�'�)�)�)�
�G�G�I�I�I��	�	�!�(�(�*�*�a�(�l�3�3�A�
�G�G�I�I�I�I��A�G�G�I�I�I�I������a���\�\������������2�2�2�����Q����8��,�,�,�����1��q�!�!�!�����1�Q�3���+�+�+�	
���*�a�m�S��V�V�<�<�<����*�a�m�S��V�V�U�C�C�C���!��(.��(�A�+�x��{�1�}�
$�%�	
����1��w�'�'�'�����1�Q�3���*�*�*�����8�A�:��1��4�5�}�E�E�E�	���	�	�	��	�,��*�*���=��I�I�3�4�4�4�4����A���J�E�3��5�[�F����U�H�-�-�-����S�(�Q�,�/�/�/�	
���q�������������1�%�%�%�	���r�!������������2�&�&�&�	���q�������������3�q�6�6�*�*�*�	
���*�a�f�b�1�1�1�	
���*�a�f�a��3�3�3�	
���*�a�f�s�1�v�v�g�a�i��;�;�;�	,�
�H�H�S�M�M�M�
���S��V�V�S�)�)�)����j�!�&�#�q�9�9�9��V�T�"�"�A�
����q�!����� � ������3�/�/�/����	�	�	�	�����	�	�	�	�������Q�V�V�X�X�s�+�+�+�+��'�	�	�	�
�D�		����*	
���	�	�	�	�	s*�BC�C�U
�8>T�T!�
U�Uc
���d}ttd��5}|�d|z��ddd��n#1swxYwYttd��5}t�|���|tj���}|�|dd�d|zd��	d|z|dd�<|�d��n#t$rYnwxYw	d|d	<|�d��n#t$rYnwxYw	|�	d	d	��|�d
��|�d��n#t$rYnwxYw	|�	d	d	��|�
d��|�d��n#t$rYnwxYw	|�d|z��|�d
��n#t$rYnt$rYnwxYwttd��5}|�|�
��d|zd��ddd��n#1swxYwYddd��n#1swxYwYttd��5}	t�|���|dz��}tj�d��s|�d��|���nD#t$$r7tj�d��r|�d��YnwxYwtj�d��rBttd��5}|�|��ddd��n#1swxYwYddd��n#1swxYwYttd��5}t�|���|tj���}d|z|dd�<|�|dd�d|zd��|���|���ddd��n#1swxYwYttd��5}|�
��}ddd��n#1swxYwY|�|d|zd��ttd��5}t�|���|tj���}d|z|dd�<|�|dd�d|zd��|���ttd��5}|�|�
��d|zd��ddd��n#1swxYwY|�t|jd|z��|���ddd��n#1swxYwYttd��5}|�t$tj|���|d���ddd��n#1swxYwYt0jdk�rrttd��5}|�t$tj|���|tjtjtj���ddd��n#1swxYwYtjt9tdd	��z}ttd��5}	t�|���||���}|�t|jd��|�t|j
d	��|���n#t:$rYnwxYwddd��dS#1swxYwYdSdS)Nr�wb�ar:��accessz#Readonly memory map data incorrect.�bz$Able to write to readonly memory mapr�abc�dr0z"Able to resize readonly memory mapz*Readonly memory map data file was modified�r+br3�winz1Opening mmap with size+1 should raise ValueError.z0Opening mmap with size+1 should work on Windows.�cz5Write-through memory map memory not updated properly.z8Write-through memory map data file not updated properly.z4Copy-on-write memory map data not written correctly.z4Copy-on-write test data file should not be modified.��posix)�flags�protr_�	PROT_EXEC�risabcdef)r;r
r<rr?�ACCESS_READrCrL�	TypeErrorrN�
write_byterQrS�read�sys�platform�
startswithr@rP�truncate�ACCESS_WRITEr>�ACCESS_COPYrFr#�name�MAP_PRIVATE�	PROT_READ�getattr�PermissionError)r'�mapsize�fprTrU�stuffris       r�test_access_parameterzMmapTests.test_access_parameter�s�
����
�&�$�
�
�	#�2��H�H�T�'�\�"�"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�
�&�$�
�
�1	O�1��	�	�!�(�(�*�*�g�d�6F�	�G�G�A����Q�q�q�q�T�4��<�1V�W�W�W�
B��G�|��!�!�!���	�	�@�A�A�A�A���
�
�
���
����
B���!���	�	�@�A�A�A�A���
�
�
���
����
B����q�������������	�	�@�A�A�A�A���
�
�
���
����
B����q��������T�"�"�"��	�	�@�A�A�A�A���
�
�
���
����
@�����7��#�#�#��	�	�>�?�?�?�?���
�
�
����
�
�
���
�����f�d�#�#�
O�r�� � ������D��L�!M�O�O�O�
O�
O�
O�
O�
O�
O�
O�
O�
O�
O�
O����
O�
O�
O�
O�_1	O�1	O�1	O�1	O�1	O�1	O�1	O�1	O�1	O�1	O�1	O����1	O�1	O�1	O�1	O�h�&�%�
 �
 �	(�A�

��I�I�a�h�h�j�j�'�!�)�4�4���|�.�.�u�5�5�S��I�I�Q�R�R�R����	�	�	�	���
R�
R�
R�
�<�*�*�5�1�1�R��I�I�P�Q�Q�Q���

R�����|�&�&�u�-�-�
(��&�%�(�(�(�A��J�J�w�'�'�'�(�(�(�(�(�(�(�(�(�(�(����(�(�(�(�#	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�*�&�%�
 �
 �	�A��	�	�!�(�(�*�*�g�d�6G�	�H�H�A���<�A�a�a�a�D����Q�q�q�q�T�4��<�J�
L�
L�
L�
�G�G�I�I�I�
�G�G�I�I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��&�$�
�
�	�1��F�F�H�H�E�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	������W��I�	K�	K�	K��&�%�
 �
 �	�A��	�	�!�(�(�*�*�g�d�6F�	�G�G�A���<�A�a�a�a�D����Q�q�q�q�T�4�'�>�S�
U�
U�
U�
�G�G�I�I�I��f�d�#�#�
Y�r�� � ������D��L�!W�Y�Y�Y�
Y�
Y�
Y�
Y�
Y�
Y�
Y�
Y�
Y�
Y�
Y����
Y�
Y�
Y�
Y�
���i���1�W�9�=�=�=�
�G�G�I�I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��&�%�
 �
 �	T�A����j�$�)�Q�X�X�Z�Z��QR��S�S�S�	T�	T�	T�	T�	T�	T�	T�	T�	T�	T�	T����	T�	T�	T�	T��7�g����f�e�$�$�
Q���!�!�*�d�i������W�(,�(8�'+�~�d�>O�"�Q�Q�Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q�
Q����
Q�
Q�
Q�
Q��>�G�D�+�q�$A�$A�A�D��f�e�$�$�	
����	�	�!�(�(�*�*�g�D�	�A�A�A�
�%�%�i���)�D�D�D��%�%�i���q�A�A�A��G�G�I�I�I�I��
'�����D�����	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
����	
�	
�	
�	
�	
�	
��s�=�A�A�AI)�:
C�I)�
C'�$I)�&C'�'I)�+D�0I)�
D�I)�D�I)�+E�I)�
E%�"I)�$E%�%I)�)+F*�I)�*
F7�4I)�6F7�7I)�;G)�I)�)
H�3I)�5	H�>I)�H�I)�-I�I)�I	�I)�I	�I)�)I-�0I-�	N5�0L�;A	N5�>M�N5�M�7N5�<N�N5�N"	�"N5�%N"	�&N5�5N9�<N9�BQ/�/Q3�6Q3�R0�0R4�7R4�*BX�9-V2�&X�2V6	�6X�9V6	�:;X�X�X�!<Y)�)Y-�0Y-�A\�\�	\�_*�/_
�6A_*�
_�_*�_�_*�*_.�1_.c�T�|�ttjdd��dS)N����)rFr*rr&s r�test_bad_file_desczMmapTests.test_bad_file_descs$�����'�4�9�b�$�7�7�7�7�7rc��ttd��5}d}t|��}|�|��|���t
�|���|��}ddd��n#1swxYwYt|dz��D]�}t||dz��D]t}|||�}|�|�	|��|�	|����|�|�	|dz��d���u��|�
��dS)N�wb+saabaacdeefaar3�xr7)r;r
rEr<r>rr?�rangerCrDr@)r'rT�data�nrUrX�finish�slices        r�test_tougher_findzMmapTests.test_tougher_finds`���&�%�
 �
 �	)�A�2�D��D�	�	�A�
�G�G�D�M�M�M�
�G�G�I�I�I��	�	�!�(�(�*�*�a�(�(�A�
	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)��1�Q�3�Z�Z�	;�	;�E���q��s�+�+�
;�
;���U�V�^�,��� � ��������	�	�%�0@�0@�A�A�A�� � �������!5�!5�r�:�:�:�:�
;�	
���	�	�	�	�	��A(B
�
B�Bc
��ttd��5}d}t|��}|�|��|���t
�|���|��}ddd��n#1swxYwY|�|�d��d��|�|�d��d��|�|�ddd��d��|�|�dd��d��|�|�ddd��d��|�|�ddd	��d��|�|�td����d��t|dz
|dz��D]g}t|dz
|dz��D]M}d
D]H}|�|||��}|�|�|||��||||f���I�N�hdS)Nr��one two ones�oner�ones�r7r3r�)�osonstwor��s)r;r
rEr<r>rr?rCrD�	bytearrayr�)	r'rTr�r�rU�i�j�p�expecteds	         r�
test_find_endzMmapTests.test_find_end"sd��
�&�%�
 �
 �	)�A�"�D��D�	�	�A�
�G�G�D�M�M�M�
�G�G�I�I�I��	�	�!�(�(�*�*�a�(�(�A�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
����������+�+�+����������!�,�,�,���������2�.�.��2�2�2���������*�*�A�.�.�.���������2�.�.��2�2�2���������2�.�.��3�3�3�������	�&� 1� 1�2�2�A�6�6�6���r�!�t�Q�q�S�!�!�	K�	K�A��A�2�a�4��1��%�%�
K�
K��=�K�K�A�#�y�y��A�q�1�1�H��$�$�Q�V�V�A�q�!�_�_�h��A�q�	�J�J�J�J�K�
K�	K�	Kr�c��	tjtjz}tj}d}tj}n'#t
$r}t
jd��|�d}~wwxYwtdd��D]�}t�d||dzz||���5}t�d||dzz||���5}|�	dd	��ddd��n#1swxYwYddd��n#1swxYwY��dS)
Nrzmmap flags unavailableir7r3)rhriisfor�)
rrw�
MAP_ANONYMOUSr=rx�AttributeError�unittest�SkipTestr�rD)	r'rhr=�	PROT_NONErx�er��guard�fms	         r�'test_find_does_not_access_beyond_bufferz1MmapTests.test_find_does_not_access_beyond_buffer9s���	E��$�t�'9�9�E��}�H��I���I�I���	E�	E�	E��#�$<�=�=�1�D�����	E�����q�$���	'�	'�A����2�x�1�q�5�1�!&�Y��8�8�
'�;@��Y�Y�r�8�q�4�x�#8�%*���<�<�'�?A��G�G�E�2�&�&�&�'�'�'�'�'�'�'�'�'�'�'����'�'�'�'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'��	'�	'sK�36�
A�A�A�%C2�8C�C2�C�C2�"C�#C2�2C6	�9C6	c��ttd��5}d}t|��}|�|��|���t
�|���|��}ddd��n#1swxYwY|�|�d��d��|�|�d��d��|�|�ddd��d��|�|�ddd��d��|�|�dd	d��d��|�|�dd	d��d��|�|�td����d��dS)
Nr�r�r�r�sone rr7r�r3)
r;r
rEr<r>rr?rC�rfindr�)r'rTr�r�rUs     r�
test_rfindzMmapTests.test_rfindIs���
�&�%�
 �
 �	)�A�"�D��D�	�	�A�
�G�G�D�M�M�M�
�G�G�I�I�I��	�	�!�(�(�*�*�a�(�(�A�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
���������!�,�,�,��������)�)�1�-�-�-���������B�/�/��3�3�3���������B�/�/��3�3�3���������B�/�/��3�3�3���������B�/�/��4�4�4��������6�!2�!2�3�3�Q�7�7�7�7�7r�c��ttd��5}|�ddz��ddd��n#1swxYwYttd��5}t�|���dtj���}|���|���ddd��dS#1swxYwYdS)Nr��r]r:r^)r;r
r<rr?rlr@�r'rT�mfs   r�test_double_closezMmapTests.test_double_close[s)��
�&�%�
 �
 �	"�A�
�G�G�E�D�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"��&�$�
�
�	�1����1�8�8�:�:�u�T�5E��F�F�B��H�H�J�J�J��H�H�J�J�J�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s �;�?�?�A"C
�
C�Cc��ttd��5}|�ddz��ddd��n#1swxYwYttd��5}t�|���d��5}|�t
|��dd��|�|�d��ddz��ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr�r��mzrb+rz Map size should equal file size.)r;r
r<rr?rCrEror�s   r�test_entire_filezMmapTests.test_entire_filees���
�&�%�
 �
 �	"�A�
�G�G�E�D�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"��&�%�
 �
 �	;�A�
�Y�Y�q�x�x�z�z�1�
%�
%�	;�)+����S��W�W�e�-O�P�P�P����R�W�W�U�^�^�U�T�\�:�:�:�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;sD�;�?�?�.C>�	AC&�C>�&C*	�*C>�-C*	�.C>�>D�Dc���ttd��5}|�ddz��ddd��n#1swxYwYttd��5}t�|���ddtj���5}|�t|jd��ddd��n#1swxYwYddd��dS#1swxYwYdS)	Nr\ir�r:rr���offsetr_i�8)	r;r
r<rr?rlrFrGrHr�s   r�test_length_0_offsetzMmapTests.test_length_0_offsetos���
�&�$�
�
�	(�1�
�G�G�Y�$�&�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��&�$�
�
�	E�1����1�8�8�:�:�q��t�?O��P�P�
E�TV��!�!�*�b�n�e�D�D�D�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E����
E�
E�
E�
E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E�	E�	EsC�;�?�?�;C�"C�8C�C	�C�C	�C�C �#C c�b�ttd��5}|�ddz��ddd��n#1swxYwYttd��5}|�tt
j|���dd���ddd��dS#1swxYwYdS)Nr\i��r��w+bri��r�)r;r
r<rFrPrr?�r'rTs  r�test_length_0_large_offsetz$MmapTests.test_length_0_large_offset{s!���&�$�
�
�	#�1�
�G�G�F�T�M�"�"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#��&�%�
 �
 �	1�A����j�$�)�Q�X�X�Z�Z��%/�
�
1�
1�
1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s�;�?�?�<B$�$B(�+B(c	�p�ttd��5}|�d��|���t�|���d��}|�ddd��|�|dd�dd��|���ddd��n#1swxYwYd}tt|����D]�}tt|����D]�}tt|��t||��z
��D]�}|d|�||||z�z|||zd�z}t�d	t|����}||dd�<|�|||��|�|dd�|��|������ь�t�d	d
��}gd�}	tj
|	|	|	��D].\}
}}	|�|
||���#t$rY�+wxYwgd�}	|	D])\}
}}|�t|j|
||���*|���t�d	d
��}|�t|jddd��|�t|jd
dd
��|�t|jdd
d
��|�ddd
��|�ddd��dS)Nr�s
ABCDEabcder�rs
ABCDEABCDEz'Map move should have duplicated front 5�
0123456789r7�d)i����r7rr3r�))r7r7r7)r7r7r)r7rr7)rr7r7)r7rr)rr7r)rrr7r3r0)r;r
r<r>rr?�moverCr@r�rE�max�	itertools�productrPrF)r'rTr�r��dest�src�countr�rU�offsets�sourcerRs            r�	test_movezMmapTests.test_move�sb��
�&�%�
 �
 �	�A�
�G�G�M�"�"�"�
�G�G�I�I�I����1�8�8�:�:�r�*�*�B��G�G�A�q�!�������R����U�M�3\�]�]�]��H�H�J�J�J�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	����#�d�)�)�$�$�	�	�D��S��Y�Y�'�'�
�
��"�3�t�9�9�s�4��~�~�#=�>�>���E�#�E�T�E�{�T�#�c�%�i�-�-@�@�4��U�
���CT�T�H��	�	�"�c�$�i�i�0�0�A��A�a�a�a�D��F�F�4��e�,�,�,��$�$�Q�q�q�q�T�8�4�4�4��G�G�I�I�I�I�
�
�
�I�I�b�#����'�'�'��"+�"3�G�W�g�"N�"N�	�	��F�D�$�
����v�t�T�*�*�*�*���
�
�
���
����7�7�7��")�	F�	F��F�D�$����j�!�&�&�$��E�E�E�E�	���	�	�	��I�I�b�!�������*�a�f�a��A�6�6�6����*�a�f�a��A�6�6�6����*�a�f�a��A�6�6�6�	���q�!�Q����	���q�!�Q�����s$�B!C�C�
C�H0�0
H=�<H=c�(�t�dt��}tt��D]}|�||dd��� tt��D](}|dz}|||<|�|||���)dS)Nr7rz+anonymously mmap'ed contents should be zero�)rr=r�rC)r'rU�x�bs    r�test_anonymouszMmapTests.test_anonymous�s����I�I�b�(�#�#���x���	L�	L�A����Q�q�T�1�J�
L�
L�
L�
L��x���	&�	&�A��D��A��A�a�D����Q�q�T�1�%�%�%�%�	&�	&rc	�n�t�dd��}|�|j��|�t	td������|�d��|�|���t	td������|�d��|�|���t	tdd������|�d��|�|���d��|�d��|�|�d��t	tdd������|�d��|�|�d��t	tdd������|�d��|�|�d	��t	tdd������|�d
��|�|�d��t	td
d������dS)Nr7�rr�rr/rfr�r��	i���)	r�
addCleanupr@r<�bytesr�rNrCro�r'rUs  r�
test_read_allzMmapTests.test_read_all�s����I�I�b�"��������� � � �	
����e�B�i�i� � �!�!�!�	���q�	�	�	���������5��r���#3�#3�4�4�4�	���q�	�	�	���������5��q�"���#6�#6�7�7�7�	���r�
�
�
���������3�'�'�'�	���q�	�	�	����������u�U�1�b�\�\�':�':�;�;�;�	���q�	�	�	����������U�5��B�<�<�%8�%8�9�9�9�	���q�	�	�	����������U�5��B�<�<�%8�%8�9�9�9�	���q�	�	�	����������e�E�!�R�L�L�&9�&9�:�:�:�:�:rc�:�t�dd��}|�|j��|�t|jd��|�t|jd��|�t|jgd���dS)Nr7r��foog@)r3r0r/)rr�r@rFrmror�s  r�test_read_invalid_argzMmapTests.test_read_invalid_arg�s����I�I�b�"��������� � � ����)�Q�V�U�3�3�3����)�Q�V�S�1�1�1����)�Q�V�Y�Y�Y�7�7�7�7�7rc��tttd������}t�dt	|����}||dd�<|�|dd�|��ddddddtjddd	d
f}|D]<}|D]7}|dd�D]*}|�||||�||||����+�8�=dS�N�r7rr3r/�i,r�i��i���)r��reversedr�rrErCrp�maxsize)r'�srU�indicesrX�stop�steps       r�test_extended_getslicez MmapTests.test_extended_getslice�s���(�5��:�:�&�&�'�'���I�I�b�#�a�&�&�!�!����!�!�!������1�1�1��q�!�!�!��d�A�q�"�c�3�;��B��T�J���	9�	9�E��
9�
9��#�A�B�B�K�9�9�D��$�$�Q�u�T�$��%7�%&�u�T�$��%7�9�9�9�9�9�
9�	9�	9rc�0�tttd������}t�dt	|����}ddddddt
jddd	d
f}|D]�}|D]�}|dd�D]�}||dd�<|�|dd�|��t|��}||||�}tt|����}|||||�<|||||�<|�|dd�t|����������dSr�)	r�r�r�rrErpr�rC�list)	r'r�rUr�rXr�r��Lr�s	         r�test_extended_set_del_slicez%MmapTests.test_extended_set_del_slice�s?���(�5��:�:�&�&�'�'���I�I�b�#�a�&�&�!�!���d�A�q�"�c�3�;��B��T�J���
	5�
	5�E��
5�
5��#�A�B�B�K�
5�
5�D��A�a�a�a�D��$�$�Q�q�q�q�T�1�-�-�-��Q���A��U�4��_�-�D� ��$���0�0�D�)-�A�e�D��o�&�)-�A�e�D��o�&��$�$�Q�q�q�q�T�5��8�8�4�4�4�4�
5�
5�
	5�
	5rc��|�d|z��|�d��|�d|dz
z��|���t�|���d��S)Nr-r.r/r)r<r>rr?)r'rT�halfsizes   r�make_mmap_filezMmapTests.make_mmap_file�so��	�����!�"�"�"�	�������	����(�Q�,�'�(�(�(�	���
�
�
��y�y�!�(�(�*�*�a�(�(�(rc	�@�ttd��}|���ttd��5}|�tdt
j|���dt
j���ddd��dS#1swxYwYdS)Nr�r:zcannot mmap an empty filerr^)r;r
r@�assertRaisesRegexrPrr?rlr�s  r�test_empty_filezMmapTests.test_empty_files����&�%� � ��	���	�	�	�
�&�$�
�
�	<�1��"�"�:�#>�#'�9�a�h�h�j�j�!�*.�*:�
#�
<�
<�
<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s�AB�B�Bc�z�ttd��}	tj}|�||��}|���|���|dz}ttd��}dD]{}	t�|���||���}|�dd��|�dd���_#tttf$rY�xwxYw|���ttd��}t�|���||z
|���}|�|dd�d	��|���	|�d
��|�t|��d
��|�
t|jdd��|�|dd�d	��ttd��}|�dd��|�|���|d
z��|���|�|���|d
z��n#t"$rYnwxYw|���|���	t%jt��dS#t($rYdSwxYw#|���	t%jt��w#t($rYwwxYwxYw)
Nr�r0rc)r�r7Nr�rr3r/r.r8r9r:)r;r
r�ALLOCATIONGRANULARITYr�r@r?rCrPrm�
OverflowErrorrQrErFrNrOrRrSr#rr*)r'rTr�rUr{r�s      r�test_offsetzMmapTests.test_offsets���&�%� � ��4	��1�H��#�#�Q��1�1�A�
�G�G�J�J�J�
�G�G�J�J�J���l�G��V�U�#�#�A�(�
+�
+��+��	�	�!�(�(�*�*�g�f�	�E�E�A��$�$�Q��*�*�*��$�$�Q��*�*�*�*��#�I�}�=�����D�����
�G�G�I�I�I��V�U�#�#�A��	�	�!�(�(�*�*�g��&8��	�J�J�A����Q�q��s�V�V�,�,�,�
�G�G�I�I�I�
;�����
�
�
�
� � ��Q����-�-�-��!�!�*�a�f�c�1�=�=�=�� � ��1�Q�3���0�0�0����&�&�����q�!����� � ������8�c�>�:�:�:����	�	�	�� � ������8�c�>�:�:�:�:���
�
�
���
����"
�G�G�I�I�I�
�G�G�I�I�I�
��	�&�!�!�!�!�!���
�
�
����
�����
�G�G�I�I�I�
��	�&�!�!�!�!���
�
�
���
������s��A(K:�AC�K:�C6�3K:�5C6�6BK:�J�C9K:�
J"�K:�!J"�"K:�K)�)
K7�6K7�:L:�L*�)L:�*
L7�4L:�6L7�7L:c�V�Gd�dtj��}|t��dS)Nc��eZdZd�ZdS)�*MmapTests.test_subclass.<locals>.anon_mmapc�8�tjj|dg|�Ri|��S)Nr7)r�__new__)�klass�args�kwargss   rr�z2MmapTests.test_subclass.<locals>.anon_mmap.__new__Ks'���y�(���D�T�D�D�D�V�D�D�DrN)�__name__�
__module__�__qualname__r��rr�	anon_mmapr�Js(������
E�
E�
E�
E�
Err�)rr=)r'r�s  r�
test_subclasszMmapTests.test_subclassIsN��	E�	E�	E�	E�	E��	�	E�	E�	E�	�	�(�����rrxzneeds mmap.PROT_READc��d}ttd��5}|�d|z��ddd��n#1swxYwYttd��5}t�|���|tj���}|�t|jd��ddd��dS#1swxYwYdS)Nrr\r]r:rkr�)r;r
r<rr?rxrFrm)r'r{r|rTrUs     r�test_prot_readonlyzMmapTests.test_prot_readonlyOs+����
�&�$�
�
�	#�2��H�H�T�'�\�"�"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�
�&�$�
�
�	9�1��	�	�!�(�(�*�*�g�D�N�	�C�C�A����i���%�8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9�	9�	9s"�=�A�A�AC�C	�C	c�P�|�tjt��dSr")�assertIsr�errorr*r&s r�
test_errorzMmapTests.test_errorXs���
�
�d�j�'�*�*�*�*�*rc�|�d}ttd��5}|�dt|��z��ddd��n#1swxYwYttd��5}t�|���t|����}ddd��n#1swxYwYt
t|����D]p}|�|���|��|�	||��|�|���|dz���q|�
t|j	d��|�|dd�|��|�d��t
t|����D]�}|�|���|��|�|�
��||��|�|���|dz����|�
t|j
��|�d��|�|�d��d	��|�|���d
��|�d��|�d��|�|���d
��|�|dd�d��|�td
����|�|���d��|�|dd�d��|�
t|jd��dS)Nr�r\r�rcr3�xrr/s345r5r2s
012bar6789sbazr�s
012barbaz9sba)r;r
r<rErr?r�rCrOrnrFrPrN�	read_byteror�)r'r�r|rTrUr�s      r�test_io_methodszMmapTests.test_io_methods[s~����
�&�$�
�
�	%�2��H�H�T�#�d�)�)�^�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�
�&�%�
 �
 �	1�A��	�	�!�(�(�*�*�c�$�i�i�0�0�A�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1��s�4�y�y�!�!�	,�	,�A����Q�V�V�X�X�q�)�)�)�
�L�L��a��!�!�!����Q�V�V�X�X�q��s�+�+�+�+����*�a�l�G�<�<�<�����1�1�1��t�$�$�$�	���q�	�	�	��s�4�y�y�!�!�	,�	,�A����Q�V�V�X�X�q�)�)�)����Q�[�[�]�]�D��G�4�4�4����Q�V�V�X�X�q��s�+�+�+�+����*�a�k�2�2�2�	���q�	�	�	����������F�+�+�+���������1�%�%�%�	���q�	�	�	�	���������������1�%�%�%�����1�1�1��}�-�-�-�	���	�&�!�!�"�"�"���������1�%�%�%�����1�1�1��}�-�-�-����*�a�g�u�5�5�5�5�5s#�&A
�
A�A�*;B1�1B5�8B5c�J�dD]�}t�dd��}|�|��|�|d|��|�d��|�|���|��|�����dS)N)���r�r7r3r)rrnrCrNrr@)r'r�rUs   r�test_non_ascii_bytezMmapTests.test_non_ascii_byte}s��� �	�	�A��	�	�"�a� � �A�
�L�L��O�O�O����Q�q�T�1�%�%�%�
�F�F�1�I�I�I����Q�[�[�]�]�A�.�.�.�
�G�G�I�I�I�I�
	�	r�ntzrequires Windowsc��d}d}t��}t��}t�dt|��|���}||dd�<t�dt|��|���}||dd�<|�|dd�|��|�|dd�|��|���|���t�dt|��|���}||dd�<t�dt|��|���}||dd�<|�|dd�|��|�|dd�|��|���|���|�td��5t�ddd���ddd��dS#1swxYwYdS)Nr�s
abcdefghijr7��tagnamer
r�r3)rrrErCr@r�rm)r'�data1�data2�tagname1�tagname2�m1�m2s       r�test_tagnamezMmapTests.test_tagname�s������!�#�#��!�#�#���Y�Y�r�3�u�:�:�x�Y�
8�
8����1�1�1��
�Y�Y�r�3�u�:�:�x�Y�
8�
8����1�1�1������A�A�A���&�&�&�����A�A�A���&�&�&�
���
�
�
�
���
�
�
��Y�Y�r�3�u�:�:�x�Y�
8�
8����1�1�1��
�Y�Y�r�3�u�:�:�x�Y�
8�
8����1�1�1������A�A�A���&�&�&�����A�A�A���&�&�&�
���
�
�
�
���
�
�
�
�
#�
#�I�y�
9�
9�	(�	(��I�I�b�!�Q�I�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�G3�3G7�:G7c��t�dd��}t��}t�dd|���}|�tj|��tj|����dS)Nr7r�r)rr�
assertGreaterrp�	getsizeof)r'rr
rs    r�test_sizeofzMmapTests.test_sizeof�si���Y�Y�r�3�
�
�� �"�"��
�Y�Y�r�3��Y�
0�
0�����3�=��,�,�c�m�B�.?�.?�@�@�@�@�@rc��t��}t�dd|���}	t�dd|���dd�n#YnxYw|���ttd��5}|�d��ddd��n#1swxYwYttd��}t�|���d��}|���	|�d��n#YnxYw	|dd�n#YnxYw|���dS)	Nr7��r�r\s
xxxxxxxxxxrcr)rrr@r;r
r<r?rQ)r'r
rUr|rTs     r�test_crasher_on_windowsz!MmapTests.test_crasher_on_windows�sn��!�"�"���I�I�b�$��I�0�0��	��I�I�b�$��I�0�0����3�3�3��	��D����	���	�	�	��&�$�
�
�	�2��H�H�W����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��������I�I�a�h�h�j�j�!�$�$��	���	�	�	�	�
�H�H�Q�K�K�K�K��	��D����	�
�a�a�a�D�D�D��	��D����	���	�	�	�	�	s5�%A�A�B%�%B)�,B)�D�D!�%
D0�0D4c�F�tj��}	|�t��5t�|���d��}ddd��n#1swxYwY|���dS#|���wxYw�Nr)�socketrFr*rr?r@)r'r�rUs   r�test_invalid_descriptorz!MmapTests.test_invalid_descriptor�s���

�M�O�O��	��"�"�7�+�+�
.�
.��I�I�a�h�h�j�j�"�-�-��
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.�
�G�G�I�I�I�I�I��A�G�G�I�I�I�I���s.�B
�.A)�B
�)A-�-B
�0A-�1B
�
B c���t�dd��5}|�|j��ddd��n#1swxYwY|�|j��dS)Nr7r)r�assertFalse�closed�
assertTruer�s  r�test_context_managerzMmapTests.test_context_manager�s���
�Y�Y�r�2�
�
�	'�!����Q�X�&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'������!�!�!�!�!s�A�A�
Ac�@�|�t��5}t�dd��5}t�#1swxYwY	ddd��n#1swxYwY|�|jtd��|�|jd��dS)Nr7rz)wrong exception raised in context managerzcontext manager failed)rF�	Exceptionrr*�assertIsInstance�	exceptionr$r#)r'�excrUs   r�test_context_manager_exceptionz(MmapTests.test_context_manager_exception�s���
�
�
�y�
)�
)�	�S����2�r�"�"�
�a��
�
�
�
�
����
�
�
�
�
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
���c�m�W�I�	K�	K�	K������":�;�;�;�;�;s,�A�?�A	�A�A	�A�A�Ac��t�dd��}tj|��}|�|��|��~t	��|�|��d��dS)Nr7r�)r�weakref�refr�r)r'�mm�wrs   r�test_weakrefzMmapTests.test_weakref�sh��
�Y�Y�r�2�
�
��
�[��_�_���
�
�b�b�d�d�B����������
�
�b�b�d�d�D�!�!�!�!�!rc��t�dd��}|�|�d��d��|�|�d��d��|�|�d��d��|�|�d	��d
��dS)Nr7r�rrr�r3syzr0�pythonr5)rrCr<)r'r/s  r�0test_write_returning_the_number_of_bytes_writtenz:MmapTests.test_write_returning_the_number_of_bytes_written�s���
�Y�Y�r�2�
�
��������#����*�*�*�������$����+�+�+�������%���!�,�,�,�������)�,�,�a�0�0�0�0�0rc�(�t�dd��}|�|j��|�d��	|�d��n%#t
$r|�d��YnwxYw|�|�d��d��|�t|j
��|�t|jd��|�t|jd	��dS)
Nr7i rr�zresizing not supported�rr6ra)
rr�r@rorQrS�skipTestrCrFrPrrnr<r�s  r�test_resize_past_poszMmapTests.test_resize_past_pos�s����I�I�b�$��������� � � �	���t����	4�
�H�H�T�N�N�N�N���	4�	4�	4��M�M�2�3�3�3�3�3�	4�������������S�)�)�)����*�a�k�2�2�2����*�a�l�B�7�7�7����*�a�g�v�6�6�6�6�6s�A"�"B�Bc��t�dd��}|�t��5||zddd��n#1swxYwY|�t��5|dzddd��dS#1swxYwYdS)Nr7r�r0)rrFrmr�s  r�test_concat_repeat_exceptionz&MmapTests.test_concat_repeat_exception�s���I�I�b�"����
�
�
�y�
)�
)�	�	�
��E�E�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�y�
)�
)�	�	�
��E�E�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s#�A�A�A�-B�B�Bc��t�dd��}|�|j��|�d��|���}|�|��tj�d��r1|�	t|jdtd����dSdS)Nr7r�r3�linuxr3)rr�r@r<r>�assertIsNonerprqrrrFr*rE)r'r/�results   r�test_flush_return_valuez!MmapTests.test_flush_return_values����Y�Y�r�2�
�
�������!�!�!�
����������������&�!�!�!��<�"�"�7�+�+�	D�
���g�r�x��C�	�N�N�C�C�C�C�C�	D�	Drc
�0�tjd��}tjd��}d}td�|D����}t||��D�]@\}}d|z}||z
}d}	d|dz|d	z|d
zf}
t	t
d��5}|�|��|���tj	|	|
��D�]�\}}
tt|��}t�|���|||���5}|�
|
��|�t|����}|�|��|�|�d
��|��|�|�d��t'|����|�|�d��t'|
����|�|�d��t'|����ddd��n#1swxYwY|�t|����}|�|�����	ddd��n#1swxYwY��BdS)Nzr<mmap.mmap closed=False, access=(?P<access>\S+), length=(?P<length>\d+), pos=(?P<pos>\d+), offset=(?P<offset>\d+)>z<mmap.mmap closed=True>)�2r�ri@Bi���c3�TK�|]#}|dztjztjzV��$dS)r0N)rr�)�.0r{s  r�	<genexpr>z&MmapTests.test_repr.<locals>.<genexpr>sU����N�N�9@�!�A���)C�C��4�5�N�N�N�N�N�Nrr])�ACCESS_DEFAULTrlrurtrrr�rfr�)r_r�r_r�posr�)rJ�compile�tuple�zipr;r
r<r>r�r�ryrr?rNrW�repr�assertIsNotNonerC�grouprA)r'�open_mmap_repr_pat�closed_mmap_repr_pat�mapsizesr�r�r{r�r�accesses�	positionsr|r_rF�accintr/rWs                 r�	test_reprzMmapTests.test_reprs
���Z�
'�(�(�� "�z�*D�E�E��:���N�N�DL�N�N�N�N�N��"�7�H�5�5�	0�	0�O�F�G��'�>�D��v�%�F�7�H��F�B�J���	�6�1�9�=�I��f�e�$�$�
0������������
�
�
�#,�#4�X�y�#I�#I�0�0�K�F�C�$�T�6�2�2�F����2�9�9�;�;�#)�*0�*0�#�2�2�
M�68�������� 2� 8� 8��b��� B� B���,�,�U�3�3�3��(�(����X�)>�)>��G�G�G��(�(����X�)>�)>��F���L�L�L��(�(����U�);�);�S��X�X�F�F�F��(�(����X�)>�)>��F���L�L�L�
M�
M�
M�
M�
M�
M�
M�
M�
M�
M�
M����
M�
M�
M�
M�1�6�6�t�B�x�x�@�@�E��(�(��/�/�/�/�0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0��
	0�	0s8�
B
J	�DH8	�,J	�8H<
�<J	�?H<
�<J	�	J
	�J
	�madvisez
needs madvisec�*�dtz}t�d|��}|�td��5|�tj|��ddd��n#1swxYwY|�td��5|�tjd��ddd��n#1swxYwY|�td��5|�tjdd��ddd��n#1swxYwY|�td��5|�tjttj��ddd��n#1swxYwY|�	|�tj��d��|�	|�tjt��d��|�	|�tjt|��d��|�	|�tjdd��d��|�	|�tjd|��d��dS)Nr0r7zmadvise start out of boundszmadvise length invalidrzmadvise length too large)
r=rr�rPrT�MADV_NORMALr�rpr�rC)r'rRrUs   r�test_madvisezMmapTests.test_madvise7s����8�|���I�I�b�$����
�
#�
#�J�0M�
N�
N�	.�	.�
�I�I�d�&��-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�
�
#�
#�J�0M�
N�
N�	,�	,�
�I�I�d�&��+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�
�
#�
#�J�0H�
I�
I�	/�	/�
�I�I�d�&��2�.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�
�
#�
#�M�3M�
N�
N�	?�	?�
�I�I�d�&��#�+�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�������4�#3�4�4�d�;�;�;�������4�#3�X�>�>��E�E�E�������4�#3�X�t�D�D�d�K�K�K�������4�#3�Q��:�:�D�A�A�A�������4�#3�Q��=�=�t�D�D�D�D�DsH�!A.�.A2�5A2�!C�C�C�'"D�D�D�;1E8�8E<�?E<c�j�t}d|z}td�t|��D����}t�d|��}||dd�<|�|��|�t
|��|��|�|d|�|d|���dS)z�If the mmap is backed by the pagefile ensure a resize up can happen
        and that the original data is still in place
        r0c3�>K�|]}tjd��V��dS�r�N�r�getrandbits�rCrs  rrDzCMmapTests.test_resize_up_when_mapped_to_pagefile.<locals>.<genexpr>Q�-����F�F�q�V�'��*�*�F�F�F�F�F�Frr7N�r=r�r�rrQrCrE�r'�
start_size�new_sizer�rUs     r�&test_resize_up_when_mapped_to_pagefilez0MmapTests.test_resize_up_when_mapped_to_pagefileJs���
�
��z�>���F�F�E�*�4E�4E�F�F�F�F�F���I�I�b�*�%�%����!�!�!��	�����������Q����*�*�*�����;�J�;���k�z�k�):�;�;�;�;�;rc�j�t}|dz}td�t|��D����}t�d|��}||dd�<|�|��|�t
|��|��|�|d|�|d|���dS)z�If the mmap is backed by the pagefile ensure a resize down up can happen
        and that a truncated form of the original data is still in place
        r0c3�>K�|]}tjd��V��dSrZr[r]s  rrDzEMmapTests.test_resize_down_when_mapped_to_pagefile.<locals>.<genexpr>`r^rr7Nr_r`s     r�(test_resize_down_when_mapped_to_pagefilez2MmapTests.test_resize_down_when_mapped_to_pagefileYs���
�
���?���F�F�E�*�4E�4E�F�F�F�F�F���I�I�b�*�%�%����!�!�!��	�����������Q����*�*�*�����9�H�9��t�I�X�I��7�7�7�7�7rc���dtz}t}ttd��}|�|��	t�|���|��}t�|���|��}|�t��5|�|��ddd��n#1swxYwY|�t��5|�|��ddd��n#1swxYwY|�	��|�|��|�
|���|��|�
tj
|�����j|��|�	��dS#|�	��wxYw)zqIf more than one mapping is held against a named file on Windows, neither
        mapping can be resized
        r0r�N)r=r;r
rsrr?rFr*rQr@rCrRr#�stat�st_size)r'ra�reduced_sizerTrrs      r�+test_resize_fails_if_mapping_held_elsewherez5MmapTests.test_resize_fails_if_mapping_held_elsewherehs���
��\�
���������	�
�
�:����	����1�8�8�:�:�z�2�2�B����1�8�8�:�:�z�2�2�B��"�"�7�+�+�
(�
(��	�	�,�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(��"�"�7�+�+�
(�
(��	�	�,�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(��H�H�J�J�J��I�I�l�#�#�#����R�W�W�Y�Y��5�5�5����R�W�Q�X�X�Z�Z�0�0�8�,�G�G�G�
�G�G�I�I�I�I�I��A�G�G�I�I�I�I���sU�A4G�1C�G�C�G�C�G�8D�G�D�G�!D�"BG�G!c��dtz}t}t��}d}td�t|��D����}t�d||���}t�d||���}||d|�<|�|d|�|��|�t��5|�|��ddd��n#1swxYwY|�|�	��|��|�|d|�|��|�|d|�|��dS)z�If a more than one mapping exists of the same name, none of them can
        be resized: they'll raise an Exception and leave the original mapping intact
        r0r�c3�>K�|]}tjd��V��dSrZr[r]s  rrDzUMmapTests.test_resize_succeeds_with_error_for_second_named_mapping.<locals>.<genexpr>�s-����G�G�q�V�'��*�*�G�G�G�G�G�Grr7rN)
r=rr�r�rrCrFr*rQrR)r'rarjr
�data_lengthr�rrs        r�8test_resize_succeeds_with_error_for_second_named_mappingzBMmapTests.test_resize_succeeds_with_error_for_second_named_mapping�s~��
��\�
���!�#�#�����G�G�E�+�4F�4F�G�G�G�G�G��
�Y�Y�r�:�w�Y�
7�
7��
�Y�Y�r�:�w�Y�
7�
7����<�K�<������L�[�L�)�4�0�0�0�
�
�
�w�
'�
'�	$�	$��I�I�l�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$���������J�/�/�/�����L�[�L�)�4�0�0�0�����L�[�L�)�4�0�0�0�0�0s�C#�#C'�*C'c	�b
�Gd�d��}tjtjtjtjg}tjtjtjg}|D�]�}||��5\}}|�td��5||��ddd��n#1swxYwYddd��n#1swxYwY||��5\}}|�td��5||��d�ddd��n#1swxYwYddd��n#1swxYwY||��5\}}|�td��5||��dd�ddd��n#1swxYwYddd��n#1swxYwY||��5\}}|�td��5|d|��d�ddd��n#1swxYwYddd��n#1swxYwY||��5\}}|�td��5|�|����ddd��n#1swxYwYddd��n#1swxYwY||��5\}}|�td��5|�dd	|����ddd��n#1swxYwYddd��n#1swxYwY���|D�]+}||��5\}}|�td��5d
||��d�<ddd��n#1swxYwYddd��n#1swxYwY||��5\}}|�td��5d||��dd�<ddd��n#1swxYwYddd��n#1swxYwY||��5\}}|�td��5d|d|��d�<ddd��n#1swxYwYddd��n#1swxYwY||��5\}}|�td��5|�	d	d|����ddd��n#1swxYwYddd��n#1swxYwY||��5\}}|�td��5|�
|����ddd��n#1swxYwYddd��n#1swxYwY��-dS)zj
        gh-103987: Test that mmap objects raise ValueError
                for closed mmap files
        c�"�eZdZdd�Zd�Zd�ZdS)�KMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext�returnNc��||_dSr"r^)r'r_s  r�__init__zTMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__init__�s
��$����rc�Z��ttd��|_|j�t	jd����|j���t�|j���d|j	����G�fd�d��}�|fS)Nr�r�r^c���eZdZ�fd�ZdS)�`MmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__enter__.<locals>.Xc�0������dSr)r@r�s �r�	__index__zjMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__enter__.<locals>.X.__index__�s������	�	�	�!�rrN)r�r�r�rz)rUs�r�Xrx�s.�������"�"�"�"�"�"�"rr{)
r;r
rTr<r�	randbytesr>rr?r_)r'r{rUs  @r�	__enter__zUMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__enter__�s�����f�e�,�,�������V�-�c�2�2�3�3�3���������I�I�d�f�m�m�o�o�s�4�;�I�G�G��"�"�"�"�"�"�"�"�"�"�
�1�v�
rc�8�|j���dSr")rTr@)r'�exc_type�	exc_value�	tracebacks    r�__exit__zTMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__exit__�s����������r)rsN)r�r�r�rur}r�r�rr�MmapClosedByIntContextrr�sF������
%�
%�
%�
%�
�
�
�
�
�
�
�
rr�zmmap closed or invalidN�r0r��1r3s
1111111111s11111)rrlrtrurEr�rProrDr�rn)r'r��read_access_modes�write_access_modesr_rUr{s       r�!test_mmap_closed_by_int_scenariosz+MmapTests.test_mmap_closed_by_int_scenarios�s�
��	�	�	�	�	�	�	�	�,
��������	
��
������
��(�	)�	)�F�'�'��/�/�
�6�A�q��+�+�J�8P�Q�Q����a�a�c�c�F�F�������������������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�(�'��/�/�
 �6�A�q��+�+�J�8P�Q�Q� � ��a�a�c�c�B�h�K�K� � � � � � � � � � � ���� � � � �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 ����
 �
 �
 �
 �(�'��/�/�
$�6�A�q��+�+�J�8P�Q�Q�$�$��a�a�c�c�B��l�O�O�$�$�$�$�$�$�$�$�$�$�$����$�$�$�$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$����
$�
$�
$�
$�(�'��/�/�
%�6�A�q��+�+�J�8P�Q�Q�%�%��b�1�1�3�3��m�$�$�%�%�%�%�%�%�%�%�%�%�%����%�%�%�%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%����
%�
%�
%�
%�(�'��/�/�
 �6�A�q��+�+�J�8P�Q�Q� � ��F�F�1�1�3�3�K�K�K� � � � � � � � � � � ���� � � � �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 ����
 �
 �
 �
 �(�'��/�/�
)�6�A�q��+�+�J�8P�Q�Q�)�)��F�F�4��A�A�C�C�(�(�(�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)����
)�
)�
)�
)��)�	&�	&�F�'�'��/�/�
,�6�A�q��+�+�J�8P�Q�Q�,�,�"+�A�a�a�c�c�B�h�K�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,�(�'��/�/�
/�6�A�q��+�+�J�8P�Q�Q�/�/�&.�A�a�a�c�c�B��l�O�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/�(�'��/�/�
0�6�A�q��+�+�J�8P�Q�Q�0�0�'/�A�b�1�1�3�3��m�$�0�0�0�0�0�0�0�0�0�0�0����0�0�0�0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0�(�'��/�/�
&�6�A�q��+�+�J�8P�Q�Q�&�&��F�F�1�a�����%�%�%�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&����
&�
&�
&�
&�(�'��/�/�
&�6�A�q��+�+�J�8P�Q�Q�&�&��L�L�����%�%�%�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&����
&�
&�
&�
&��#	&�	&sR�/C�B+�C�+B/�/C�2B/�3C�C	�	C	�D-�7D�
D-�D�D-�D�D-�-D1	�4D1	�F�"F�6F�F�F�	F�
F�F	� F	�/H�G.�"H�.G2�2H�5G2�6H�H		�H		�I;�:I$�I;�$I(�(I;�+I(�,I;�;I?	�I?	�K3�0 K�K3�K � K3�#K �$K3�3K7	�:K7	�M"�/M�?M"�M�M"�M�M"�"M&	�)M&	�8O�N4�(O�4N8�8O�;N8�<O�O	�O	�!P4�P�P4�P!�!P4�$P!�%P4�4P8	�;P8	�
R,�) R�	R,�R�R,�R�R,�,R0	�3R0	�T"�!T�?T"�T�T"�T�T"�"T&	�)T&	N)7r�r�r�r(r+rZr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
skipUnless�hasattrrr�rrr	r#rvrrrrr r%r+r1r4r8r:r?rSrWrcrfrkror�r�rrr r  sN������������\�\�\�|@�@�@�D8�8�8����$K�K�K�.
'�
'�
'� 8�8�8�$���;�;�;�
E�
E�
E�1�1�1�-�-�-�^
&�
&�
&�;�;�;�*8�8�8�9�9�9�5�5�5�()�)�)�<�<�<�7�7�7�r����X�����{�3�3�5K�L�L�9�9�M�L�9�+�+�+� 6� 6� 6�D����X����D��*<�=�=�(�(�>�=�(�<��X����D��*<�=�=�A�A�>�=��\�A��X����D��*<�=�=���>�=��4�X����D��*<�=�=�	�	�>�=�	�"�"�"�
<�<�<�"�"�"�1�1�1�7�7�7����D�D�D�"0�"0�"0�H�X������I�6�6��H�H�E�E�I�H�E�$�X����D��*<�=�=�<�<�>�=�<��X����D��*<�=�=�8�8�>�=�8��X����D��*<�=�=���>�=��.�X����D��*<�=�=�1�1�>�=�1�(T&�T&�T&�T&�T&rr c��eZdZd�Zd�Zd�Zd�Zd�Zd�Ze	j
eje
kd��d���Ze	j
eje
kd��d	���Zd
S)�LargeMmapTestsc�.�tt��dSr"�rr
r&s rr(zLargeMmapTests.setUp�����v�����rc�.�tt��dSr"r�r&s rr+zLargeMmapTests.tearDown�r�rc��tjdd�dkstjdkr tddtd��z��t	t
d��}	|�|��|�|��|���n\#tttf$rB	|���n#ttf$rYnwxYwtjd���wxYw|S)	Nr/rd�darwin�	largefilez-test requires %s bytes and a long time to run�r�z*filesystem does not have largefile support)rprqrrAr;r
rNr<r>r*r�rPr@r�r�)r'�
num_zeroes�tailrTs    r�_make_test_filezLargeMmapTests._make_test_file�s���<�����u�$�$����(@�(@��[�?�#�k�BR�BR�R�
T�
T�
T�������		R�
�F�F�:����
�G�G�D�M�M�M�
�G�G�I�I�I�I����
�3�	R�	R�	R�
����	�	�	�	���]�+�
�
�
���
�����#�$P�Q�Q�Q�	R�����s0�>B�C7�6C�
C7�C�C7�C�C7c�@�|�dd��5}t�|���ddtj���5}|�|dd��ddd��n#1swxYwYddd��dS#1swxYwYdS)Nl��� rlr�i���� )r�rr?rlrC�r'rTrUs   r�test_large_offsetz LargeMmapTests.test_large_offsets��
�
!�
!�+�t�
4�
4�	3�����1�8�8�:�:�q��T�EU��V�V�
3�Z[�� � ��9��r�2�2�2�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s5�;B�A;�/B�;A?	�?B�A?	�B�B�Bc�"�|�dd��5}tjdkr�|�t��5t
�|���dt
j���ddd��n#1swxYwY|�t��5t
�|���dt
j���ddd��n#1swxYwYt
�|���dt
j���5}|�	|�
��d��ddd��n#1swxYwYddd��dS#1swxYwYdS)Nl��r�r�r^rr�)r�rpr�rFr�rr?rlrPrCrRr�s   r�test_large_filesizez"LargeMmapTests.test_large_filesize	sU��
�
!�
!�+�t�
4�
4�		8���{�[�(�(��&�&�}�5�5�P�P��I�I�a�h�h�j�j�+�d�>N�I�O�O�O�P�P�P�P�P�P�P�P�P�P�P����P�P�P�P��&�&�z�2�2�F�F��I�I�a�h�h�j�j�!�D�4D�I�E�E�E�F�F�F�F�F�F�F�F�F�F�F����F�F�F�F����1�8�8�:�:�w�t�7G��H�H�
8�A�� � ������;�7�7�7�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8����		8�		8�		8�		8�		8�		8s}�+F�:B�<F�B	�F�B	�F�-:C3�'F�3C7	�7F�:C7	�;<F�7)E,� F�,E0	�0F�3E0	�4F�F�Fc��d}|t|��dzz
}|t|��z}|�||��5}t�|���dtj���5}|�|||�|��ddd��n#1swxYwYddd��dS#1swxYwYdS)Ns  DEARdear  r0rr^)rEr�rr?rlrC)r'�boundaryr�rXrYrTrUs       r�_test_around_boundaryz$LargeMmapTests._test_around_boundarys5�����3�t�9�9��>�)���c�$�i�i���
�
!�
!�%��
.�
.�	5�!����1�8�8�:�:�q��1A��B�B�
5�a�� � ��5��9��t�4�4�4�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	5�	5s6�:B=�:B%�B=�%B)	�)B=�,B)	�-B=�=C�Cz!test cannot run on 32-bit systemsc�:�|�t��dSr")r�rr&s r�test_around_2GBzLargeMmapTests.test_around_2GB����"�"�3�'�'�'�'�'rc�:�|�t��dSr")r�rr&s r�test_around_4GBzLargeMmapTests.test_around_4GB#r�rN)r�r�r�r(r+r�r�r�r�r�r�rpr�rr�r�r�rrr�r��s����������������"3�3�3�

8�
8�
8�5�5�5��X����s�*�,O�P�P�(�(�Q�P�(��X����s�*�,O�P�P�(�(�Q�P�(�(�(rr��__main__)r) �test.supportrrrrrr�test.support.import_helperr	�test.support.os_helperr
rr�r#rJr�rrrrpr-rr=�getpidrrr��TestCaser r�r��mainr�rr�<module>r�s�������������������5�4�4�4�4�4�1�1�1�1�1�1�1�1�����	�	�	�	�	�	�	�	�����
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
������}�V�����=��2�9�2�9�;�;�2�2�2��(�(�(�(��N�
�(�
�L�
M�
M�M�I&�I&�I&�I&�I&��!�I&�I&�I&�V:(�:(�:(�:(�:(�X�&�:(�:(�:(�z�z����H�M�O�O�O�O�O��r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists